Skip to content

Configuration

Token Optimizer reads configuration from two places: environment variables and a config.json file. Environment variables take precedence. When both set the same setting, the environment variable wins for that run, and config.json holds the persistent default.

For script installs on Claude Code, config.json lives at ~/.claude/token-optimizer/config.json. Plugin installs use the resolved plugin-data directory; other Python adapters use their runtime home/data directory. Do not assume every install writes the legacy Claude path. It stores feature flags, consent status, the pricing tier, and timestamps. The v5 command and the various setup-* and consent commands write to it. Most users never edit it by hand; the commands keep it consistent.

Each active compression feature has a config.json key and an environment override. Setting the environment variable to 0 disables the feature for that run regardless of the persisted value.

VariableDefaultEffect
TOKEN_OPTIMIZER_BASH_COMPRESSenabledSet to 0 to disable Bash output compression for eligible read-only commands
TOKEN_OPTIMIZER_COMMAND_FILTERS<runtime-home>/token-optimizer/command-filters.tomlPath to a user TOML file that adds read-only commands to the compression allowlist and excludes commands you never want compressed; composes with the built-ins, safety-gated, fail-open
TOKEN_OPTIMIZER_READ_CACHEenabledSet to 0 to disable the read cache entirely (no delta, no skeleton substitution)
TOKEN_OPTIMIZER_READ_CACHE_DELTAenabledSet to 0 to disable delta mode only (re-reads return full content instead of a diff)
TOKEN_OPTIMIZER_READ_CACHE_MODEsoft_blockSelect the read-cache mode: soft_block, warn, shadow, or block. See the modes table below.
TOKEN_OPTIMIZER_STRUCTURE_MAPoff (measurement)Set to beta to enable structure-map compression event logging. This is a separate measurement toggle, not the mode selector above.
TOKEN_OPTIMIZER_QUALITY_NUDGESenabledSet to 0 to disable the quality-drop alerter
TOKEN_OPTIMIZER_LOOP_DETECTIONenabledSet to 0 to disable the retry-loop detector
TOKEN_OPTIMIZER_FIRST_READ_SHADOWenabledSet to 0 to disable both first-read skeleton measurement and active first-read skeleton serving
TOKEN_OPTIMIZER_FIRST_READ_ACTIVEenabledSet to 0 to disable active first-read skeleton serving for promoted cohorts
TOKEN_OPTIMIZER_VERBOSITY_MIN_FILL25Gentle lean-output nudge fill floor; below 75% fill it also requires session efficiency below 75. At 75-89% the strong tier uses fill alone; at 90%+ no context is added

The matching config.json keys are: v5_bash_compress, read_cache_enabled, v5_delta_mode, v5_structure_map_beta, v5_quality_nudges, v5_loop_detection, v5_first_read_shadow, and v5_first_read_active (the v5_ prefix is a legacy naming convention; the features are current). Manage the v5_ gates with measure.py v5 enable|disable <feature>. The read-cache master gate has its separate environment override.

The read cache operates in one of four modes, selected with TOKEN_OPTIMIZER_READ_CACHE_MODE (for example TOKEN_OPTIMIZER_READ_CACHE_MODE=shadow). The default is soft_block.

ModeBehavior
soft_blockDefault. On an unchanged re-read, substitute a compact result (delta or structure map) instead of the full file. May deny an eligible redundant Read and inject its bounded structure map; ineligible reads pass through.
warnAllow the full re-read, but emit a warning that the file was already read. No substitution.
shadowMeasure what substitution would have saved without changing the result the model sees. Used for validation.
blockDeny redundant reads even without an eligible structure map (reason-only then); safety and escape-hatch checks still apply. This mode table describes the Python Read hook, not the separate OpenClaw config.
VariableDefaultEffect
TOKEN_OPTIMIZER_CONTEXT_SIZEauto-detectedOverride the assumed context window size for all commands. Equivalent to the --context-size flag.
TOKEN_OPTIMIZER_QUALITY_WINDOW20Rolling window size for ratio-based quality signals
TOKEN_OPTIMIZER_TOOL_CALL_WARNautoTool-call warning threshold; scales with the context window
TOKEN_OPTIMIZER_TOOL_CALL_CRITICALautoTool-call critical threshold; scales with the context window
TOKEN_OPTIMIZER_RELEVANCE_THRESHOLD0.3Minimum relevance score for collecting a checkpoint as a continuity candidate or teaser
TOKEN_OPTIMIZER_RELEVANCE_FULL_THRESHOLD0.5Minimum relevance score for emitting the full recovered-data block instead of a one-line teaser
TOKEN_OPTIMIZER_DENSITY_MIN_MESSAGES6Keep decision-density scoring neutral until the session has this many messages
TOKEN_OPTIMIZER_FRESH_NUDGE_QUALITY70Quality-score threshold used by the fresh-session nudge
TOKEN_OPTIMIZER_FRESH_NUDGE_MIN_FILL45Minimum context fill % used by the fresh-session nudge
VariableDefaultEffect
TOKEN_OPTIMIZER_CHECKPOINT_RETENTION_DAYS7Days to keep checkpoints before cleanup
TOKEN_OPTIMIZER_CHECKPOINT_PER_SESSION5Newest checkpoints each session keeps, plus its newest of each trigger, so a busy session never removes another session’s checkpoints
TOKEN_OPTIMIZER_CHECKPOINT_RETENTION_MAX400Disk ceiling across all sessions; under it, each session’s newest checkpoint goes last. OpenCode reads it as the number of past sessions to scan for restore (default 50 there)
TOKEN_OPTIMIZER_CHECKPOINT_TELEMETRYoffSet to 1 to enable the checkpoint-stats telemetry summary
TOKEN_OPTIMIZER_PROGRESSIVE_CHECKPOINTSenabledSet to 0, false, no, or off to disable progressive checkpoint capture at the 20/35/50/65/80% fill bands
TOKEN_OPTIMIZER_CHECKPOINT_FILES10Maximum active/recent files retained in extracted checkpoint state
TOKEN_OPTIMIZER_CHECKPOINT_EVENT_MAX1000Maximum checkpoint telemetry events retained after pruning
TOKEN_OPTIMIZER_CHECKPOINT_COOLDOWN_SECONDS90Minimum time between checkpoint fires
TOKEN_OPTIMIZER_COMPACT_RESTORE_BUDGET8 secondsWall-clock budget for the standalone compact-restore hook; runners also impose their shared deadline
TOKEN_OPTIMIZER_RESUME_RECENCY_MIN480 minutesMaximum age for the same-project fallback on a vague continue request; a named-topic match has its own scoring path

These tune checkpoint_relevance_score, the IDF-weighted content-overlap scorer that decides which prior checkpoint (if any) a continuation prompt resumes. Every value is hard-clamped to a safe range at load — an out-of-range or non-numeric value is coerced into the range rather than trusted — so a mis-set knob can never force the score to a constant or flip the F1 sign. Defaults are calibrated against the real checkpoint pool; change them only with a reason.

VariableDefaultSafe range (clamped)Effect
TOKEN_OPTIMIZER_CHECKPOINT_RELEVANCE_THRESHOLD0.250.1–0.9Minimum score for the pull tool to resume a checkpoint. Lower widens recall (risks vague-continue false matches); higher demands a stronger topical/resume signal.
TOKEN_OPTIMIZER_RELEVANCE_RESUME_BONUS_PRECISION_FLOOR0.50.0–0.99Floor for the precision-scaled resume-intent bonus: effective factor = floor + (1−floor)·precision. Higher protects verbose genuine resumes; lower makes a cross-client graze pay more for its unmatched tokens.
TOKEN_OPTIMIZER_RELEVANCE_PATH_TF_WEIGHT0.50.0–2.0Weight of the path-identity frequency boost (a token recurring across a checkpoint’s file paths out-ranks the same word quoted once in prose). 0 disables the boost.
TOKEN_OPTIMIZER_RELEVANCE_PATH_TF_CAP81–50Cap on the per-token path frequency counted by the boost, so one mega-repeated path segment cannot dominate recall.
TOKEN_OPTIMIZER_RELEVANCE_IDF_CAP3.01.0–100.0Cap on each term’s IDF contribution, so one ultra-rare token cannot spike the score (keyword-stuffing defense).
VariableDefaultEffect
TOKEN_OPTIMIZER_EDIT_BATCH_WRITE_THRESHOLD4Write-count delta that triggers an edit-batch checkpoint
TOKEN_OPTIMIZER_EDIT_BATCH_FILE_THRESHOLD3Changed-file delta that triggers an edit-batch checkpoint
TOKEN_OPTIMIZER_CONTINUITY_MAX_SESSIONS5Maximum prior sessions represented in a continuity hint
TOKEN_OPTIMIZER_CONTINUITY_PER_SESSION_SCAN3Maximum checkpoint candidates scanned per prior session
TOKEN_OPTIMIZER_RESUME_TOPIC_BAR0.22Residual-topic score above which a resume request is treated as naming a topic rather than asking for the most recent same-project checkpoint

These seven names are read by opencode/src/util/env.ts and exist only there; the feature names also exist on other platforms, but these exact environment-variable names are not cross-platform aliases.

VariableDefaultPlatformEffect
TOKEN_OPTIMIZER_SMART_COMPACTIONtrueOpenCodeEnable compaction context injection
TOKEN_OPTIMIZER_CONTINUITYtrueOpenCodeEnable session continuity
TOKEN_OPTIMIZER_NUDGEStrueOpenCodeEnable quality nudges
TOKEN_OPTIMIZER_ACTIVITYtrueOpenCodeEnable activity-mode tracking
TOKEN_OPTIMIZER_TRENDStrueOpenCodeEnable trends collection
TOKEN_OPTIMIZER_DATA_DIRplatform-global location + token-optimizer/OpenCodeComplete data directory, used verbatim. Only the unset default appends token-optimizer/. See OS defaults.
TOKEN_OPTIMIZER_CHECKPOINT_MAX_CHARS2000OpenCodeMaximum characters of checkpoint content injected on continuity restore

Do not apply Python defaults to the TypeScript extensions merely because an environment name is shared.

Adapter / nameNative defaultEffect
OpenCode TOKEN_OPTIMIZER_CHECKPOINT_TTL300 secondsCheckpoint TTL in the native config
OpenCode TOKEN_OPTIMIZER_CHECKPOINT_RETENTION_MAX50Prior-session scan limit for continuity
OpenCode TOKEN_OPTIMIZER_RELEVANCE_THRESHOLD0.6Relevance floor for restored prior-session content
OpenCode TOKEN_OPTIMIZER_FRESH_NUDGE_MIN_FILL50%Fresh-session nudge fill floor (Python default is 45%)
OpenCode TOKEN_OPTIMIZER_TOOL_CALL_WARN / TOKEN_OPTIMIZER_TOOL_CALL_CRITICAL25 / 40Tool-call thresholds; explicit null plugin options disable them
OpenClaw TOKEN_OPTIMIZER_CHECKPOINT_COOLDOWN_MS90000 msCheckpoint policy cooldown
OpenClaw TOKEN_OPTIMIZER_RUNTIME_EVALUATION_COOLDOWN_MS30000 msRuntime checkpoint-policy evaluation cooldown
OpenClaw TOKEN_OPTIMIZER_CONTINUITY_MAX_AGE_DAYS7 daysPrior-session age bound
Pi TOKEN_OPTIMIZER_PI_HOME~/.pi/agent/token-optimizerComplete data directory, not a parent home

OpenCode plugin options can set feature gates and numeric defaults; environment reads then apply as defined by the adapter. An explicit dataDir option wins over its environment value. Pi persists enabled, retainDays (1-365, default 7), archiveToolOutput, and continuity in its own settings.json; the three boolean gates default off. OpenClaw keeps its own host/plugin config, not Python config.json.

VariableDefaultEffect
TOKEN_OPTIMIZER_HOST127.0.0.1Bind host for the dashboard server
TOKEN_OPTIMIZER_DASHBOARD_HOST127.0.0.1Dashboard-specific bind host; set to 0.0.0.0 for LAN access before setup-daemon
TOKEN_OPTIMIZER_DASHBOARD_TIMEOUT30 secondsTotal retry budget when opening the dashboard server
TOKEN_OPTIMIZER_TURN_PRELOAD_MAX40Maximum recent sessions whose per-turn data is embedded in a static dashboard
TOKEN_OPTIMIZER_TURN_PRELOAD_MAX_BYTES8000000 bytesSkip larger transcripts during static dashboard preload; served mode fetches older/oversized sessions on demand

Dashboard ports are fixed per runtime: 24842 (Claude Code), 24843 (Codex), 24844 (Hermes), 24845 (Copilot), 24846 (Cursor), 24847 (Antigravity), 24848 (Grok Build). They are assigned by the engine. A port entry does not prove that setup-daemon is allowed on that runtime: it is blocked by the foreign-runtime guard for OpenCode, Copilot, Hermes, Cursor, Antigravity, and Grok. The --port flag on dashboard overrides the port for a one-off serve.

VariableDefaultEffect
TOKEN_OPTIMIZER_TRENDS_RETENTION_DAYSunlimitedDays to keep rows in the history database
TOKEN_OPTIMIZER_ARCHIVE_RETENTION_HOURS24Hours to keep archived tool results
TOKEN_OPTIMIZER_ARCHIVE_RETENTION_MAX_FILES1000Maximum files across tool archives; oldest sessions are removed first
TOKEN_OPTIMIZER_ARCHIVE_RETENTION_MAX_BYTES104857600Maximum aggregate tool-archive bytes (100 MiB); oldest sessions are removed first
TOKEN_OPTIMIZER_QUALITY_CACHE_RETENTION_DAYS7Days to keep quality-cache snapshots; 0 means unlimited
TOKEN_OPTIMIZER_ORPHAN_RETENTION_DAYS30Minimum inactivity age for orphan plugin-data reclamation (hard floor: 7 days)

Per-session file caches are auto-deleted after 48 hours and are not configurable. See Your data and privacy for the full storage map.

VariableDefaultEffect
TOKEN_OPTIMIZER_STATUS_BARenabledSet to 0 to hide the desktop bar
TOKEN_OPTIMIZER_STATUS_BAR_ANIMATEenabledSet to 0 to stop Clawd animation
TOKEN_OPTIMIZER_STATUS_BAR_SIZEfullslim selects an initial single-line desktop band and a slim terminal status line. A saved desktop size choice wins over this initial default

Keep-Warm is opt-in and managed by the keepwarm-* commands; there are no plain feature-flag environment variables for it. Consent and billing mode are persisted in config.json and read by keepwarm-consent-status.

Production LLM pinging remains disabled even after consent; there is no supported environment switch here to turn it on. See Keep-Warm.

VariableDefaultEffect
TOKEN_OPTIMIZER_SUBAGENT_CACHE_1Hadvise-onlyUnset: the subagentPromptCacheTtl: "1h" verdict is a recommendation only — Token Optimizer never writes the key, it advises with your own numbers and the exact command. 1, true, on, or yes: opt in to the automatic write (with the 14-day tripwire). 0, false, off, or no: never, and if the setting was already applied by Token Optimizer, it is removed (Claude Code only)

Two Claude Code environment variables also gate the feature without any opt-out flag: CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL and FORCE_PROMPT_CACHING_5M both outrank the settings key, so Token Optimizer does nothing while either is set. See Subagent prompt cache.

VariableDefaultEffect
TOKEN_OPTIMIZER_COPILOT_USD_PER_CREDIT0.01USD value of one Copilot AI credit, for cost display
TOKEN_OPTIMIZER_COPILOT_PREMIUM_RATE0.04USD per premium request
TOKEN_OPTIMIZER_COPILOT_CAPS_JSON(unset)JSON override of the Copilot capability map when upstream fixes outpace the shipped matrix, for example '{"pretooluse_ctx": true}'
TOKEN_OPTIMIZER_COPILOT_BINcopilotOverride the Copilot CLI executable used by doctor and hook-bridge checks
TOKEN_OPTIMIZER_COPILOT_HOME~/.copilot or auto-detectedOverride the Copilot home used by Token Optimizer; validated before use
VariableDefaultEffect
TOKEN_OPTIMIZER_ANTIGRAVITY_HOME~/.geminiOverride the Antigravity home used by the adapter; accepted only under $HOME
TOKEN_OPTIMIZER_ANTIGRAVITY_BINfirst agy on PATHOverride the agy binary the doctor probes; must be an absolute, trusted path
TOKEN_OPTIMIZER_BASH_COMPRESS1 (on)Set 0 to disable command-output compression on Antigravity

The pricing tier drives every cost and savings calculation. Set it with measure.py pricing-tier <tier>; the value persists in config.json. The default is anthropic.

TierPricing basis
anthropicAnthropic API direct rates (default)
vertex-globalGoogle Vertex AI global rates
vertex-regionalVertex AI regional rates (a regional premium applies)
bedrockAWS Bedrock rates
VariableDefaultEffect
TOKEN_OPTIMIZER_PRICES_FILEbundled pricing/prices.jsonOverride the schema-1 price-card file. Read once at import; malformed/oversized files are ignored
TOKEN_OPTIMIZER_BUNDLED_PRICES1Set exactly 0 to skip bundled price cards and use built-in fallback rates
VariableDefaultEffect
TOKEN_OPTIMIZER_RUNTIMEclaudeSelect the platform adapter: claude, codex, opencode, copilot, hermes, cursor, antigravity, or grok. Pi is a separate extension, not a Python runtime value
TOKEN_OPTIMIZER_SKIP_VERIFYoffSet to 1 to skip checksum verification during script install (not recommended)
TOKEN_OPTIMIZER_DEBUGoffEmit runtime-detection and refetch-guard diagnostics to stderr
TOKEN_OPTIMIZER_NO_PROC_SCANoffSkip best-effort process-tree scans used as runtime-detection fallbacks
TOKEN_OPTIMIZER_ALLOW_UNSAFE_RUNTIME_HOMEoffFor container layouts, relax only the under-$HOME containment check; absolute, existing, non-symlink directory checks still apply
HERMES_HOME~/.hermesOverride the Hermes home directory for the Hermes adapter
TOKEN_OPTIMIZER_PYTHONtrusted interpreter discoveryOverride the Python executable used by the hook launcher on Claude Code and Codex and by the Copilot, Cursor, Antigravity, and Grok installers; the path must pass their trust checks
TOKEN_OPTIMIZER_CURSOR_HOME~/.cursorToken Optimizer-only Cursor home override; absolute safe directory under HOME by default. Cursor has no documented CURSOR_HOME alias
TOKEN_OPTIMIZER_CURSOR_BINagent/cursor discoveryOverride the Cursor binary probed by doctor
TOKEN_OPTIMIZER_GROK_HOME~/.grokToken Optimizer-only Grok home override, ahead of host GROK_HOME; safer than changing Grok’s own home when inspecting native Windows data from WSL
TOKEN_OPTIMIZER_GROK_BINPATH grok or <grok-home>/bin/grokOverride the binary candidate probed by the Grok doctor
TOKEN_OPTIMIZER_PI_HOME~/.pi/agent/token-optimizerComplete data directory for the separate Pi extension, used verbatim
TOKEN_OPTIMIZER_RECLAIM_ORPHANED_DATAoffOpt in with a truthy value to deleting eligible old orphaned plugin-data identities. Detection alone never deletes; the age floor is 7 days
VariableDefaultEffect
TOKEN_OPTIMIZER_ARCHIVE_EXEMPT_TOOLS(unset)Comma-separated fnmatch globs added to the built-in list of MCP tools whose full output stays inline
TOKEN_OPTIMIZER_ARCHIVE_EXEMPT_DEFAULTSenabledSet to off, false, 0, or none to remove the built-in archive exemptions
TOKEN_OPTIMIZER_LIVE_STATE_TOOLS(unset)Comma-separated fnmatch globs (at most 64, parsed once per process) matched against the full tool name, marking extra tools as live-state. A match does three things: the re-fetch guard never denies an identical repeat, the archive writer stores no args_hash fingerprint for the tool, and the archive footer invites a fresh call for current state — so a broad glob like mcp__* disables the whole re-fetch loop, stronger than TOKEN_OPTIMIZER_REFETCH_GUARD_WINDOW_SECONDS=0 which only lifts the deny. Browser-family tools (chrome, playwright, puppeteer, browser, browse, chromium, devtools, computer-use keywords in either name segment, plus tool names containing screenshot, snapshot or page_state) are already covered; use this for servers with unconventional names
TOKEN_OPTIMIZER_REDACT_PATTERNS_FILE<platform-home>/token-optimizer/redact-patterns.jsonPath to a JSON file of extra credential redaction patterns, added to the built-in set. See Data and privacy
TOKEN_OPTIMIZER_COST_PER_MTOKmodel-derivedPositive numeric override for the input-token price estimate used by the hook-safe compression-savings path

These controls change estimates, cohort gates, collection bounds, or cache behavior. They are user-settable, but primarily useful for validation and advanced deployments.

VariableDefaultEffect
TOKEN_OPTIMIZER_OVERHEAD_CACHE_TTL3600 secondsTTL for cached structural-overhead calculations
TOKEN_OPTIMIZER_DASHBOARD_HOOK_BUDGET20 secondsWall-clock budget for a dashboard rebuild that runs inside a hook (Stop / SessionEnd). A rebuild the budget stops is finished by a detached background process, so raising this only changes how much of the work happens inside the hook itself. Clamped to 1..600
TOKEN_OPTIMIZER_COMPONENTS_CACHE_TTL60 secondsIn-process TTL for repeated component scans
TOKEN_OPTIMIZER_LOOP_CONTINUATION_FACTOR1.0Multiplier applied to measured looped volume for the separately labelled avoided-continuation estimate
TOKEN_OPTIMIZER_COHORT_MIN3Minimum size for each compared cohort in contamination and retrieval estimates
TOKEN_OPTIMIZER_AVG_READ_TOKENS2500Per-avoided-read token estimate used by retrieval savings
TOKEN_OPTIMIZER_AVOIDED_READS_CAP8Per-session cap on avoided reads in the retrieval estimate
TOKEN_OPTIMIZER_ROUTABLE_OPUS_FRACTION0.3Fraction of Opus work treated as routable in the model-routing opportunity calculation
TOKEN_OPTIMIZER_BASELINE_OPUS_SHARE0.0 (unset)Explicit pre-Token-Optimizer Opus share; values outside (0, 1] fall back to measured history
TOKEN_OPTIMIZER_AVOIDABLE_WRITE_FRACTION0.3Share of full-file Writes treated as avoidable in the separately labelled output-waste opportunity
TOKEN_OPTIMIZER_AVOIDABLE_WRITE_TOKENS1500Output-token delta assigned to each avoidable full-file Write opportunity
TOKEN_OPTIMIZER_CACHE_DROP_GAP_SECONDS300Call gap treated as a likely 5-minute cache expiry in cache-drop estimates
TOKEN_OPTIMIZER_BASELINE_ONBOARDING_DAYS1Initial install-period days excluded from baseline construction
TOKEN_OPTIMIZER_BASELINE_WINDOW_DAYS30Early-history window used to construct the baseline
TOKEN_OPTIMIZER_BASELINE_WINSOR_PCT0.99Percentile used to cap high-token sessions in baseline means
TOKEN_OPTIMIZER_BASELINE_MIN_SESSIONS30Minimum sessions required for a stable early-history baseline
TOKEN_OPTIMIZER_AFTER_MIN_SESSIONS10Minimum recent sessions required before trusting the after-window comparison
TOKEN_OPTIMIZER_MIN_INPUT_TOKENS1000Minimum input tokens for a session to enter the interactive-work comparison pool
TOKEN_OPTIMIZER_MIN_DURATION_MINUTES1.0Minimum duration for a session to enter the interactive-work comparison pool
TOKEN_OPTIMIZER_INITIAL_BACKFILL_DAYS365Lookback used by the one-time deep session-history backfill
TOKEN_OPTIMIZER_COLLECT_COMMIT_BATCH200Number of collected sessions committed per backfill batch
TOKEN_OPTIMIZER_COLLECT_MAX_PER_RUN150Maximum newly parsed sessions per collection run; 0 is unbounded
TOKEN_OPTIMIZER_INITIAL_BACKFILL_MAX_ATTEMPTS5Maximum deep-backfill attempts before returning to the rolling window
TOKEN_OPTIMIZER_BASELINE_ADOPTenabledSet exactly 0 to prevent adopting a well-formed frozen baseline from a prior sibling plugin identity
TOKEN_OPTIMIZER_WEIGHT_MIN_ANCHOR_SESSIONS100Minimum anchor-session sample for the session-weight measuring-stick pool
TOKEN_OPTIMIZER_STRUCTURE_MAP_TREESITTERoffTruthy value enables the optional tree-sitter backend when compatible runtime and grammar packages are installed
TOKEN_OPTIMIZER_FAIL_STREAK_THRESHOLD3Different-output failures of the same command before the thrash burn nudge
TOKEN_OPTIMIZER_INLINE_SCRIPT_THRESHOLD8Repeated executions of a normalized inline script before its thrash nudge (bodies at least 300 characters)
TOKEN_OPTIMIZER_ARCHIVE_ACTIVE_GRACE_SECONDS86400 secondsArchive heartbeat grace protecting recently active sessions during aggregate retention
TOKEN_OPTIMIZER_ARCHIVE_CLEANUP_INTERVAL_SECONDS60 secondsMinimum interval between recursive archive retention scans

Supported controls versus implementation markers

Section titled “Supported controls versus implementation markers”

The tables document supported configuration and adapter-specific overrides. Child-process markers, generated-script constants, test fixtures, and unsupported experimental switches are not setup steps or tuning controls. Do not copy a name from a debug log into your environment unless its adapter documentation supports that use.

The keys below cover the primary feature controls, not every internal cache, timestamp, or consent field. Edit through the commands rather than by hand; the table documents what each key holds.

KeyHoldsSet by
v5_bash_compressBash compression on/offv5 enable|disable bash_compress
read_cache_enabledRead cache on/offPersisted config; per-run TOKEN_OPTIMIZER_READ_CACHE=0 disables
v5_delta_modeDelta mode on/offv5 enable|disable delta_mode
v5_structure_map_betaStructure-map event logging on/offv5 enable|disable structure_map_beta
v5_quality_nudgesQuality nudges on/offv5 enable|disable quality_nudges
v5_loop_detectionLoop detection on/offv5 enable|disable loop_detection
v5_first_read_shadowFirst-read measurement gatev5 enable|disable first_read_shadow
v5_first_read_activePromoted first-read serving gatev5 enable|disable first_read_active
quality_bar_disabledSticky status-line opt-outsetup-quality-bar --uninstall
enterprise_consent_shown, v5_welcome_shownNotice/opt-out flags; missing or unreadable config fails open, not an affirmative consent barrierWelcome bootstrap and consent --grant|--reset
daemon consentBookmarkable-URL preferencedaemon-consent --set
pricing_tierActive pricing tierpricing-tier <tier>
keepwarm_consent and billing modeKeep-Warm enablement statekeepwarm-enable, keepwarm-disable

These are the behavior-driving host settings covered by this audit, not an exhaustive host schema or keys in Token Optimizer’s config.json. Reading them does not mean Token Optimizer implements or controls every host feature.

Host / keyHow Token Optimizer uses it
Claude model, primaryModel, defaultModelModel/window detection and routing advice
Claude autoCompactWindowTop-level compact window; read for fill and compact-window replay, never written by recommendations
Claude modelSettings[model-id].autoCompactWindowPer-model setting written by /autocompact; takes precedence over top-level. "auto" selects the tuned default instead of falling through
Claude subagentPromptCacheTtlRead for advice; only explicit enable or TOKEN_OPTIMIZER_SUBAGENT_CACHE_1H=1 can set "1h" in user settings. User/managed/project overrides are preserved
Claude envHost-injected overrides and custom redaction/filter configuration
Claude permissions, hooks, statusLine, enabledPlugins, compactInstructions, cleanupPeriodDaysAudit, safe hook/status-line setup, compaction instructions, retention inspection
Claude mcpServers, _disabledMcpServers, includeGitInstructions, effortLevelMCP inventory/toggles and coaching
Codex model, project_doc_max_bytes, project_doc_fallback_filenamesModel detection and AGENTS.md footprint calculation
Codex permissions.filesystem.deny_readExcludes forbidden paths from scans
NameEffect in Token Optimizer
CLAUDE_CODE_AUTO_COMPACT_WINDOWWins over per-model and top-level compact-window settings. Valid explicit windows clamp to 100K-1M and the model limit
CLAUDE_AUTOCOMPACT_PCT_OVERRIDEUsed-percent threshold applied to the resolved compact window; 1 to below 100 compacts earlier. Read-only: Token Optimizer does not delete it
CLAUDE_CODE_DISABLE_1M_CONTEXTExact 1 forces the per-model window resolver to 200K, ahead of its window overrides
CLAUDE_MODEL, ANTHROPIC_MODEL, CODEX_MODELModel hints where no stronger session model is available
CLAUDE_CODE_DISABLE_MCP_DEFERREDExact 1 disables the deferred-tool assumption in MCP overhead estimation
CLAUDE_CODE_SAVE_HOOK_ADDITIONAL_CONTEXTRead-hook persistence signal used by substitution safety/logging
CLAUDE_CONFIG_DIR, CODEX_HOME, HERMES_HOMEHost-home discovery; validated by the relevant adapter
CLAUDE_PLUGIN_DATA, CLAUDE_PLUGIN_ROOT, CLAUDE_SESSION_IDHost-supplied plugin/session identity, not recommended user tuning knobs
GROK_HOMEGrok’s own home; prefer TOKEN_OPTIMIZER_GROK_HOME for a Token Optimizer-only override
MAX_MCP_OUTPUT_TOKENSHost output cap used for MCP cap-proximity estimates, not changed by the archiver

The effective compact window resolves host env, then per-model settings, then top-level settings, then the model’s tuned default (about 967K for native 1M). The used-percent override is applied afterward. Context-size overrides and CLAUDE_CODE_DISABLE_1M_CONTEXT affect the model limit separately. This is not the generic config.json precedence below.

  1. Precedence is feature-specific. The per-model window resolver checks CLAUDE_CODE_DISABLE_1M_CONTEXT, then TOKEN_OPTIMIZER_CONTEXT_SIZE, then --context-size; do not assume a CLI flag always beats env.
  2. Environment variables win over config.json for the run.
  3. config.json holds the persistent default.
  4. Engine defaults apply when nothing else is set.

A value marked (verify) anywhere in these docs means the source did not state that detail definitively. Defaults here are source-derived, not proof of live host behavior; beta adapters still require their documented verification.

TOKEN_OPTIMIZER_RUNTIME=devin isolates shared dispatch from Claude scans. TOKEN_OPTIMIZER_DEVIN_HOME overrides the adapter’s home; otherwise absolute XDG_CONFIG_HOME/devin or ~/.config/devin is used. Overrides must remain inside HOME and cannot traverse symlinks. Native Windows is refused. Only output filtering is supported (explicit by default, automatic with install.sh --devin --auto), not generic dashboard/trends commands. Automatic mode edits only the hooks key of config.json in that home; automatic captures are kept 7 days or 200 entries. Numeric estimate retention is 30 days with at most 10,000 rows. Raw-passthrough captures are removed after successful delivery; compressed captures remain available for recovery until explicitly deleted or purged.