Skip to content

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.

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.

DetectorWhat it catches
Respond-to-bashrespondToBashCommands 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 churnThe same tool called with the same input three or more times while it keeps erroring.
Tool cascadeThree or more consecutive tool errors forming a failure chain.
LoopingHigh similarity between user messages with little forward progress, the signature of a stuck loop.
Overpowered modelA top-tier model spent on tasks a cheaper model would have handled.
Weak modelA cheap model used for work that needed a stronger one, causing rework.
Bad decompositionMonolithic prompts that try to do too much in one turn and should be split.
Wasteful thinkingExtended-thinking tokens out of proportion to the output they produced.
Output wasteOutput tokens disproportionate to the complexity of the task.
Cache instabilityCLAUDE.md patterns that break Anthropic’s prefix-based prompt cache, so the prefix is re-written.
WebSearch routingHeavy web search or fetch usage that a cheaper routing choice would serve.
PDF ingestionLarge PDF or image reads that inflate context when a cached or trimmed read would do.

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.

DetectorWhat it catches
Heartbeat model wasteHeartbeat or cron tasks running on an expensive model when a cheaper one would do.
Heartbeat over-frequencyA heartbeat interval short enough to rerun before anything has changed.
Stale cron configA cron or hook entry pointing at a path that no longer exists.
Empty runsScheduled runs that load context but produce no output.
Session history bloatSessions that run long without compaction, paying repeatedly for a bloated context.
Loop detectionRetry storms and stuck tool calls that spin without progress.
Abandoned sessionsFrequent sessions abandoned right after start, a sign of high startup overhead.
Ghost-token clustersClusters of runs that load context but return near-empty output.
Tool-loading overheadMany tool definitions loaded per session, paying full definition tokens each time.
Retry churnRepeated retries after a failure instead of stopping to diagnose.
Tool cascadeError chains that propagate across tool calls.
Overpowered modelSimple tasks routed to a top-tier model.
Weak modelComplex sessions on a model too weak for them, driving errors and retries.
Bad decompositionSeveral tasks crammed into one message, hurting accuracy.
Output wasteVerbose model output that burns output tokens.
Unused skillsInstalled 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.

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.

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.

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.

There is no per-detector command. They surface through the reports that consume them:

Terminal window
cd ~/.claude/skills/token-optimizer/scripts
python3 measure.py coach --json # detector findings in the coach blob
python3 measure.py report # detector findings in the full audit

For the fleet-wide detectors and dollar pricing:

Terminal window
cd ~/.claude/skills/fleet-auditor/scripts
python3 fleet.py audit --json # cross-system waste findings with savings

On a non-Claude runtime, prefix the runtime, for example TOKEN_OPTIMIZER_RUNTIME=codex.

SettingDefaultNotes
Confidence floor0.3Findings at or below this are suppressed.
Triage minimum5,000 tokensA session must clear this to be triaged.
Significance gate>5% of sessionsA detector is flagged only when it affects a meaningful share.
Overlap handlingde-duplicatedA weaker detector stands down when a stronger one covers the same session.

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.

None specific to the detectors. The read-cache hook that carries the PDF-ingestion check has its own variables, defined in the configuration reference.

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.

  • 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.