KBCodeKB
Unverified

Fix Disabled Telemetry Silently Downgrading Prompt Cache TTL from 1-Hour to 5-Minutes in Claude Code on Windows, macOS, and WSL2

When telemetry is disabled via DISABLE_TELEMETRY=1 or CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 (either as environment variables or in ~/.claude/settings.json), Claude Code silently downgrades prompt cache TTL from 1-hour to 5-minutes for Max plan subscribers. This causes significantly higher token usage and costs, as the shorter cache TTL means more cache misses and re-computation. The issue affects all platforms (Windows, macOS, WSL2) and applies only to Max plan subscribers — Pro plan subscribers already use 5-minute TTL. Detection is via session JSONL files in ~/.claude/projects/*/ where the usage.cache_creation field shows ephemeral_5m_input_tokens instead of ephemeral_1h_input_tokens. Anthropic confirmed the issue and shipped a client-side fix in v2.1.108 (April 13, 2026). Users should either remove telemetry-disabling flags or upgrade to v2.1.108+.

Symptoms

  • Prompt cache TTL downgrades from 1-hour to 5-minutes when DISABLE_TELEMETRY=1 or CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 is set
  • Significantly higher token usage and cost on Max plan due to cache misses
  • Session JSONL shows ephemeral_5m_input_tokens non-zero and ephemeral_1h_input_tokens zero when telemetry disabled
  • Same project/session shows 1h cache pool with telemetry ON but 5m pool with telemetry OFF
  • Billing dashboard shows higher-than-expected token consumption

Error signatures

ephemeral_1h_input_tokens: 0, ephemeral_5m_input_tokens: non-zero (when telemetry disabled)
ephemeral_1h_input_tokens: non-zero, ephemeral_5m_input_tokens: 0 (when telemetry enabled)
DISABLE_TELEMETRY=1
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1

Possible causes

  • The telemetry-disabling mechanism and the 1-hour prompt cache TTL eligibility check were coupled on the client side. When DISABLE_TELEMETRY or CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC is set, the client sends a modified request that the server interprets as ineligible for the extended 1-hour cache TTL, falling back to the default 5-minute TTL. The coupling was unintentional — there is no technical reason why disabling telemetry should affect cache TTL.
  • Per Anthropic staff (bcherny), 1-hour prompt cache is nuanced: it costs more for cache writes but less for cache reads. Whether a user benefits depends on their usage pattern (context window size, agent vs subagent queries, session length). The cache TTL tier selection heuristic was incorrectly gated on telemetry being enabled.

Solutions

Programmatic cache TTL verification script

risk: lowgithubpublished

Use a Python or shell script to programmatically verify which cache TTL tier your sessions are using. This helps diagnose whether the fix is working and monitor for regressions. The script reads session JSONL files and reports the cache tier being used.

  1. Run the verification script in your project directory
  2. Script reads all JSONL session files in ~/.claude/projects/*/
  3. Reports whether each session uses 1-hour or 5-minute cache TTL
  4. Use this to confirm the fix is working after upgrade or flag removal

Commands

grep -oP 'ephemeral_1h_input_tokens":\s*\K\d+' ~/.claude/projects/*/*.jsonl 2>/dev/null | awk '{sum+=$1} END {print "1h total:", sum}'
grep -oP 'ephemeral_5m_input_tokens":\s*\K\d+' ~/.claude/projects/*/*.jsonl 2>/dev/null | awk '{sum+=$1} END {print "5m total:", sum}'

Config examples

{
  "// Claude Code settings (~/.claude/settings.json)": "",
  "// REMOVE these flags to restore 1h cache TTL on affected versions": "",
  "// Before v2.1.108, these flags silently downgrade cache TTL": "",
  "DISABLE_TELEMETRY": null,
  "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": null
}

Risks

  • Session JSONL files may contain sensitive conversation data — handle with care
  • File paths use session ID directories that may not be immediately obvious

Verification

  • Step 1: ls ~/.claude/projects/ → expect: one or more project directories exist
  • Step 2: Run grep -c ephemeral_1h ~/.claude/projects/*/*.jsonl 2>/dev/null → expect: count > 0 for sessions with 1h cache
  • Step 3: With telemetry disabled on v2.1.108+, run the 1h grep again → expect: ephemeral_1h_input_tokens still non-zero (fix verified)
0 verified0 failed

Upgrade to Claude Code v2.1.108+ (permanent fix)

risk: lowofficialpublished

Anthropic decoupled telemetry from cache TTL selection in v2.1.108 (released April 13, 2026). Upgrading allows users to keep telemetry disabled while still receiving 1-hour prompt cache TTL. The latest version as of June 2026 is v2.1.175.

  1. Check current version: claude --version
  2. Upgrade: npm install -g @anthropic-ai/claude-code@latest
  3. Verify version ≥ 2.1.108: claude --version
  4. Keep or restore DISABLE_TELEMETRY=1 if desired
  5. Run a session and verify both telemetry is disabled AND 1h cache TTL is active

Commands

npm install -g @anthropic-ai/claude-code@latest
claude --version
npm view @anthropic-ai/claude-code version
DISABLE_TELEMETRY=1 claude -p 'say hello'

Risks

  • Upgrading may introduce unrelated breaking changes in newer versions
  • Global npm install may conflict with version managers (nvm, fnm)

Verification

  • Step 1: claude --version → expect: v2.1.108 or newer (e.g., v2.1.175)
  • Step 2: DISABLE_TELEMETRY=1 claude -p 'say hello' → expect: normal response, no errors
  • Step 3: grep ephemeral_1h ~/.claude/projects/*/*.jsonl 2>/dev/null | tail -1 → expect: ephemeral_1h_input_tokens > 0 even with DISABLE_TELEMETRY=1
0 verified0 failed

Remove telemetry-disabling flags (immediate workaround, all platforms)

risk: lowgithubpublished

Remove DISABLE_TELEMETRY=1 or CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 from your environment and ~/.claude/settings.json. This restores 1-hour prompt cache TTL immediately without requiring an upgrade. If you must disable telemetry, upgrade to v2.1.108+ where the coupling bug is fixed.

  1. Check if telemetry-disabling flags are set: grep -E 'DISABLE_TELEMETRY|CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC' ~/.claude/settings.json
  2. Also check environment: env | grep -E 'DISABLE_TELEMETRY|CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC'
  3. Remove the flag from settings.json or unset the environment variable
  4. Restart Claude Code and verify cache TTL by checking session JSONL
  5. Run a few queries and inspect ~/.claude/projects/*/<session-id>.jsonl for ephemeral_1h_input_tokens > 0

Commands

grep -E 'DISABLE_TELEMETRY|CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC' ~/.claude/settings.json
env | grep -E 'DISABLE_TELEMETRY|CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC'
grep ephemeral_1h ~/.claude/projects/*/*.jsonl 2>/dev/null | tail -5

Risks

  • Enabling telemetry sends usage data to Anthropic — some users may have privacy concerns
  • CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC also disables other non-essential network requests

Verification

  • Step 1: grep -E 'DISABLE_TELEMETRY|CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC' ~/.claude/settings.json → expect: no results (flags removed)
  • Step 2: After running claude, check grep ephemeral_1h ~/.claude/projects/*/*.jsonl 2>/dev/null | tail -1 → expect: ephemeral_1h_input_tokens > 0 (non-zero)
  • Step 3: grep ephemeral_5m ~/.claude/projects/*/*.jsonl 2>/dev/null | tail -1 → expect: ephemeral_5m_input_tokens: 0
0 verified0 failed

Agent JSON

Canonical machine-readable representation of this issue:

{
  "issue_id": "d6496819-8703-4cbd-8848-00f720b8d44a",
  "slug": "fix-disabled-telemetry-silently-downgrading-prompt-cache-ttl-from-1-hour-to-5-minutes-in-claude-code-on-windows-macos-an-t1btqn",
  "verification_status": "unverified",
  "canonical_json": "https://codekb.dev/v1/issues/fix-disabled-telemetry-silently-downgrading-prompt-cache-ttl-from-1-hour-to-5-minutes-in-claude-code-on-windows-macos-an-t1btqn"
}
← Back to all issuesPowered by CodeKB