Skip to content

Quality signals

Quality signals are the read-only alerting and metadata layer. The four features on this page add short notes or structured data to the session in real time, fired by hooks, with no content removed or rewritten.

Two are user-visible alerters: Quality Nudges warn when the session is degrading, Loop Detection flags when the model is stuck. Two are internal infrastructure: Activity Mode classifies what kind of work the session is doing, and Decision Extraction captures decisions in real time so they survive compaction. All four are on by default and run across all supported platforms.

Quality Nudges watch the running context quality score. When the score drops 15 or more points in a single measurement, or crosses below 60, a short inline note enters the context. The model surfaces it on the next turn, prompting a timely /compact before the session degrades further. The note is suppressed on the first check immediately after a compaction (to avoid false alarms right after the context was just cleaned).

Loop Detection watches for repetition. It compares the last four user messages and the last five tool results for similarity, using a confidence threshold of 0.70. When confidence is met, a short warning enters the context. Post-hoc analysis of real sessions found that loop sessions average 47,000 wasted tokens before the user notices. The notes use fixed templates and never echo your content back.

Activity Mode Detection classifies the current session into one of five modes: code, debug, review, infra, or general. Classification runs on a sliding window of the last ten tool calls after every PostToolUse event. The result feeds the active compression compaction engine, which selects mode-aware PRESERVE and DROP priorities when /compact runs. The activity log auto-prunes at 30 rows to avoid unbounded growth.

Decision Extraction monitors tool outputs in real time for decision statements, patterns like “chose X because Y”, “going with Z over W”, or “switched to”. It runs only on outputs over 500 characters (to skip short noise). Detected decisions are stored in the session database via atomic read-modify-write (SQLite BEGIN IMMEDIATE) and injected as a CRITICAL DECISIONS block at compaction time, so the context stays decision-aware after every /compact.

All four run automatically via hooks. No manual invocation is needed.

FeatureHookTrigger
Quality NudgesUserPromptSubmit (quality-cache)Quality score drops 15+ points or crosses below 60
Loop DetectionUserPromptSubmit (quality-cache)Similarity ≥ 0.70 across last 4 user messages or last 5 tool results
Activity ModePostToolUseEvery tool call, no threshold
Decision ExtractionPostToolUseTool output over 500 characters

All four features are on by default on all supported platforms. No setup is required after installation.

Quality Nudges and Loop Detection can be disabled. Activity Mode and Decision Extraction are internal infrastructure with no user-facing disable path; they run silently and impose no visible output.

Quality Nudges: environment variable

Terminal window
TOKEN_OPTIMIZER_QUALITY_NUDGES=0

Set in your shell profile or .env file. See the configuration reference for where env vars are read.

Quality Nudges: CLI disable

Terminal window
cd ~/.claude/skills/token-optimizer/scripts
python3 measure.py v5 disable quality_nudges

Loop Detection: environment variable

Terminal window
TOKEN_OPTIMIZER_LOOP_DETECTION=0

Loop Detection: CLI disable

Terminal window
cd ~/.claude/skills/token-optimizer/scripts
python3 measure.py v5 disable loop_detection

Activity Mode and Decision Extraction are internal-only. There is no disable path. They produce no user-visible output and carry zero risk (see Risk rating below).

Check current status of the quality-cache hook and signal features:

Terminal window
cd ~/.claude/skills/token-optimizer/scripts
python3 measure.py quality-cache status

Check session signal statistics (nudge count, loop count, decisions stored):

Terminal window
python3 measure.py compression-stats

Check which signal features are enabled:

Terminal window
python3 measure.py v5 status

Re-enable a disabled feature:

Terminal window
python3 measure.py v5 enable quality_nudges
python3 measure.py v5 enable loop_detection
FeatureParameterValue
Quality NudgesDrop threshold15 points
Quality NudgesFloor threshold60 (score below this also fires)
Quality NudgesCooldown5 minutes
Quality NudgesSession cap3 nudges
Quality NudgesPost-compact suppressionYes (first check after compact skipped)
Loop DetectionSimilarity threshold0.70 confidence
Loop DetectionUser message windowLast 4 messages
Loop DetectionTool result windowLast 5 results
Loop DetectionSession cap2 warnings
Loop DetectionNote styleFixed templates, no content echo
Decision ExtractionMinimum output size500 characters
Decision ExtractionSession cap10 decisions
Decision ExtractionWrite methodSQLite BEGIN IMMEDIATE (atomic)
Activity ModeClassification windowLast 10 tool calls
Activity ModeActivity log prune30 rows
Activity ModeModescode, debug, review, infra, general

None. The entire signal layer is read-only. Quality Nudges and Loop Detection add short inline notes. Activity Mode writes a local classification. Decision Extraction writes to a local SQLite database. No content is removed, rewritten, or sent anywhere. All writes are to local files you own.

VariableEffectDefault
TOKEN_OPTIMIZER_QUALITY_NUDGESSet to 0 to disable Quality Nudges1 (enabled)
TOKEN_OPTIMIZER_LOOP_DETECTIONSet to 0 to disable Loop Detection1 (enabled)

Full env var list with accepted values and load order: configuration reference.

PlatformQuality NudgesLoop DetectionActivity ModeDecision Extraction
Claude CodeFullFullFullFull
CodexPartial (quality-cache runs, hook surface differs)PartialFullFull
OthersVerifyVerifyFullFull

Codex has a different hook surface for UserPromptSubmit-based features. The quality-cache hook fires, but timing and trigger behavior may differ from Claude Code. Activity Mode and Decision Extraction use PostToolUse, which is consistent across platforms.

See the capability matrix for a full platform breakdown.