Waste detectors
A waste detector is a single rule that looks at your sessions or your config and flags one specific way tokens leak. Token Optimizer ships twelve that run on Claude Code and Codex. OpenClaw runs its own native set of sixteen detectors, tuned to its scheduled-agent surface: heartbeats, crons, and unattended fleet runs that can burn tokens with no one watching.
What they do
Section titled “What they do”Each detector takes parsed session data or a config file, looks for one pattern, and returns a finding with a confidence score. The findings feed three surfaces: Token Coach names them in conversation, Fleet Auditor prices them across systems, and the setup audit folds them into the full report.
Detectors are conservative on purpose. A finding is suppressed at or below a 0.3 confidence threshold and flagged only when it affects a meaningful share of recent sessions, so the report shows real waste, not noise. Two detectors of the same family never double-count: if a model-routing finding already covers a session, the overlapping check stands down.
The twelve detectors on Claude Code and Codex
Section titled “The twelve detectors on Claude Code and Codex”These run on parsed session history and your project config.
| Detector | What it catches |
|---|---|
| Respond-to-bash | respondToBashCommands not set to false in settings.json (unset or true), so Claude Code spends output tokens on an unrequested reply after every slash-command and !bash output. |
| Retry churn | The same tool called with the same input three or more times while it keeps erroring. |
| Tool cascade | Three or more consecutive tool errors forming a failure chain. |
| Looping | High similarity between user messages with little forward progress, the signature of a stuck loop. |
| Overpowered model | A top-tier model spent on tasks a cheaper model would have handled. |
| Weak model | A cheap model used for work that needed a stronger one, causing rework. |
| Bad decomposition | Monolithic prompts that try to do too much in one turn and should be split. |
| Wasteful thinking | Extended-thinking tokens out of proportion to the output they produced. |
| Output waste | Output tokens disproportionate to the complexity of the task. |
| Cache instability | CLAUDE.md patterns that break Anthropic’s prefix-based prompt cache, so the prefix is re-written. |
| WebSearch routing | Heavy web search or fetch usage that a cheaper routing choice would serve. |
| PDF ingestion | Large PDF or image reads that inflate context when a cached or trimmed read would do. |
The sixteen OpenClaw detectors
Section titled “The sixteen OpenClaw detectors”OpenClaw runs a native TypeScript detector engine tuned to its agent-orchestration model: scheduled heartbeats, crons, and fleet sessions that can run unattended. When Fleet Auditor detects OpenClaw, it runs all sixteen.
| Detector | What it catches |
|---|---|
| Heartbeat model waste | Heartbeat or cron tasks running on an expensive model when a cheaper one would do. |
| Heartbeat over-frequency | A heartbeat interval short enough to rerun before anything has changed. |
| Stale cron config | A cron or hook entry pointing at a path that no longer exists. |
| Empty runs | Scheduled runs that load context but produce no output. |
| Session history bloat | Sessions that run long without compaction, paying repeatedly for a bloated context. |
| Loop detection | Retry storms and stuck tool calls that spin without progress. |
| Abandoned sessions | Frequent sessions abandoned right after start, a sign of high startup overhead. |
| Ghost-token clusters | Clusters of runs that load context but return near-empty output. |
| Tool-loading overhead | Many tool definitions loaded per session, paying full definition tokens each time. |
| Retry churn | Repeated retries after a failure instead of stopping to diagnose. |
| Tool cascade | Error chains that propagate across tool calls. |
| Overpowered model | Simple tasks routed to a top-tier model. |
| Weak model | Complex sessions on a model too weak for them, driving errors and retries. |
| Bad decomposition | Several tasks crammed into one message, hurting accuracy. |
| Output waste | Verbose model output that burns output tokens. |
| Unused skills | Installed skills never invoked, paying per-message startup overhead. |
Several of these are specific to OpenClaw’s scheduled-agent surface (heartbeats, crons, empty runs, abandoned sessions); the rest retune the behavioral checks the shared engine also runs. All sixteen surface through Fleet Auditor and the OpenClaw dashboard.
When they fire
Section titled “When they fire”The session detectors run when you ask for analysis: a setup audit, a coaching conversation, or a fleet audit. They do not run on every turn. The PDF-ingestion check runs at the read-cache hook as reads happen. The OpenClaw checks run only when Fleet Auditor detects OpenClaw.
Default state
Section titled “Default state”On by default wherever Token Optimizer collects session history, because they only read and report. They never block a turn or change a model on their own. See the capability matrix.
How to turn it on and off
Section titled “How to turn it on and off”The detectors are read-only analysis. There is nothing to disable in the sense of stopping a process: they run only when you request a report, and they change nothing.
To stop seeing their findings, do not run the reports that surface them (coach, the audit, or the fleet audit). The PDF-ingestion check rides on the read-cache hook; disabling read-cache compression disables that one inline check. See Read cache for that hook’s controls.
Exact commands
Section titled “Exact commands”There is no per-detector command. They surface through the reports that consume them:
cd ~/.claude/skills/token-optimizer/scriptspython3 measure.py coach --json # detector findings in the coach blobpython3 measure.py report # detector findings in the full auditFor the fleet-wide detectors and dollar pricing:
cd ~/.claude/skills/fleet-auditor/scriptspython3 fleet.py audit --json # cross-system waste findings with savingsOn a non-Claude runtime, prefix the runtime, for example TOKEN_OPTIMIZER_RUNTIME=codex.
Defaults and thresholds
Section titled “Defaults and thresholds”| Setting | Default | Notes |
|---|---|---|
| Confidence floor | 0.3 | Findings at or below this are suppressed. |
| Triage minimum | 5,000 tokens | A session must clear this to be triaged. |
| Significance gate | >5% of sessions | A detector is flagged only when it affects a meaningful share. |
| Overlap handling | de-duplicated | A weaker detector stands down when a stronger one covers the same session. |
Risk rating
Section titled “Risk rating”None. Every detector reads session data or config and returns a finding. None of them block a turn, call a model, or change your setup. The remedies they suggest are yours to apply.
Related environment variables
Section titled “Related environment variables”None specific to the detectors. The read-cache hook that carries the PDF-ingestion check has its own variables, defined in the configuration reference.
Platform availability
Section titled “Platform availability”The twelve session detectors run on Claude Code and Codex and on any runtime where Token Optimizer collects sessions. The OpenClaw security checks run only when Fleet Auditor detects OpenClaw. See the capability matrix.
Related
Section titled “Related”- Token Coach: names these patterns in plain language during a coaching conversation.
- Fleet Auditor: prices the same patterns across every agent system with dollar figures.
- Setup audit: the full report that folds in detector findings.
- Read cache: the hook that carries the PDF-ingestion check.
- Configuration: read-cache and runtime variables.