claude-code - ✅(Solved) Fix [BUG] Disabling telemetry also disables 1-hour prompt cache TTL [2 pull requests, 1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45381Fetched 2026-04-09 08:06:45
View on GitHub
Comments
1
Participants
1
Timeline
7
Reactions
0
Participants
Timeline (top)
labeled ×5commented ×1subscribed ×1

Error Message

Error Messages/Logs

PR fix notes

PR #85: feat(skills): add /cost-impact for weekly Claude spend reports

Description (problem / solution / changelog)

Summary

New `/cost-impact` skill that computes a Claude Code cost-impact report across a time window (default 7 days), grouped by repo with per-session detail. Complements `/changelog` — the latter summarizes git history, this one summarizes Claude session history, answering "where did my Claude-time actually go this week."

What it does

Scans every `~/.claude/projects//.jsonl` main session and `//subagents/agent-*.jsonl` subagent transcript, filters turns by timestamp into the requested window, and bills each turn at its model's published list price. Key design points:

  • Per-turn per-model pricing — Opus 4.6 $5/$25, Sonnet 4.6 $3/$15, Haiku 4.5 $1/$5, older Opus 4 / 4.1 tiers at their historic $15/$75. Table sourced from platform.claude.com/docs/en/about-claude/pricing.
  • Subagent tokens roll into the parent session's total — so "what did this session cost" reflects all work done on its behalf, not just the main turns.
  • Groups by (project, parent_session_uuid, day) — a session that spans midnight is split across days so daily totals add up cleanly.
  • Flat pricing across the 1M window for 4.5+ — no 200k threshold, per Anthropic's long-context docs.

Report shape

  1. Summary — total $, total duration, total turns (main/sub/total), sessions in window, cost breakdown (input/output/cache writes 1h+5m/cache reads), without-cache reference, cache savings %
  2. Cost by model — per-model totals and share
  3. Per day — sessions, main+sub turns, costs
  4. Per repo summary table — sessions, actual $, share %
  5. Sessions grouped by repocollapsible `<details>` sections, one per repo. Summary line shows repo name, total $, session count, duration, main+sub turns. Expands to a per-session table with clickable PR links extracted from `gh pr create` calls in the scrollback.
  6. Footnotes — methodology, fast-mode/peak-hours/TTL-bug caveats

Invocation

```bash python3 skills/cost-impact/_impl.py [days] ```

The skill prompts the user whether to post the report to a gist or save locally, then runs the right `gh gist create` or `cp` command.

Dogfood test results

Ran against my own 7-day window:

``` Wrote /tmp/cost-impact.md (16,937 bytes, 64 session-days) Actual: $1,248.28 | no-cache ref: $6,960.82 | savings: 82% Repos: 11, top 3: activation-energy-game, settings, blog4 ```

Also ran with `--days 1` to verify the short-window path ($331, 5 repos, 11 session-days).

Known caveats (surfaced in the report's own footnotes)

  • Fast mode invisible: `usage` field doesn't flag `/fast` turns, so if the user hit fast mode those are under-reported by 6×. No current detection path.
  • Peak-hours quota burn (weekday 5–11am PT, per Anthropic session limits update 2026-03-26) only affects quota burn rate, not $/token. The report prices at list; peak vs off-peak is not reflected in the dollar column.
  • TTL bug (anthropics/claude-code#45381): if `DISABLE_TELEMETRY` or `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` is set, sessions silently fall from 1h to 5m cache tier. Footnote alerts the user.

Test plan

  • Dogfood with 7-day window — produces coherent $1,248 report
  • Dogfood with 1-day window — short-window edge case works
  • Verify collapsible `<details>` sections render on GitHub (tested on a gist of the output)
  • Verify PR link extraction finds `gh pr create` commands and shows titles with state
  • All pre-commit hooks pass (ruff lint/format, prettier, fast tests)

Skill structure

  • `skills/cost-impact/SKILL.md` — entry point with trigger phrases, run/output instructions, hard rules, known caveats
  • `skills/cost-impact/_impl.py` — standalone Python (~370 lines), safe to run directly: `python3 skills/cost-impact/_impl.py [days]`

🤖 Generated with Claude Code

Changed files

  • skills/cost-impact/SKILL.md (added, +166/-0)
  • skills/cost-impact/_impl.py (added, +655/-0)
  • skills/cost-impact/test_impl.py (added, +436/-0)

PR #90: docs(CLAUDE.md): don't hardcode factual claims in report output

Description (problem / solution / changelog)

Summary

Adds a short rule adjacent to Diagnostics: Code Over Prose warning against hardcoded narrative footnotes in script output.

Why

LLM-written report code naturally reaches for claims that sound measured — "0 X observed", "no errors found" — but are actually string literals that rot silently and can flip from true to false without anyone noticing.

Concrete example from #85: the `skills/cost-impact/_impl.py` TTL-bug footnote unconditionally claimed `0 ephemeral_5m_input_tokens observed`. Real data over a 7-day window was 10,531,293 c5m tokens / $57.70 — the hardcoded "reassurance" was silently lying to the user about whether they were affected by anthropics/claude-code#45381. Copilot flagged it in review.

The existing Diagnostics: Code Over Prose rule covers skill prose going stale. This is related but distinct: it covers script output asserting facts the script never computed. Both are flavors of "derive, don't declare", but in different surfaces.

The rule

Factual claims in generated output must be computed from the actual data, not hardcoded as constants. [...] If a report asserts a number or category, derive it from the input; if you can't derive it, drop the assertion or phrase it as a question the reader must answer, not a fact.

Test plan

  • Fits under the 5-line cap
  • Concrete example cited (cost-impact TTL footnote)
  • Durable, non-obvious, actionable — not already covered by existing rules
  • Distinct from Diagnostics: Code Over Prose (which is about skill prose, not script output)

🤖 Generated with Claude Code

Changed files

  • CLAUDE.md (modified, +4/-0)
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

When telemetry is disabled (e.g., via DISABLE_TELEMETRY=1 or CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1), sessions that would otherwise receive 1-hour prompt cache TTL appear to fall back to the 5-minute TTL instead.

What Should Happen?

Prompt cache TTL selection should be independent of telemetry. If a user/session would otherwise qualify for 1-hour prompt cache TTL, it should still receive it even when telemetry is disabled.

Error Messages/Logs

Steps to Reproduce

  1. Start a session with telemetry enabled.
  2. Confirm the session is using the 1-hour prompt cache tier.
  3. Start a comparable session with either DISABLE_TELEMETRY=1 or CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1.
  4. Compare the cache metadata between the two sessions.
  5. Observe that the 1-hour TTL is no longer applied when telemetry is disabled.

Note: This may not be reproducible if using bedrock and ENABLE_PROMPT_CACHING_1H_BEDROCK=1 is set. I only tested with an Anthropic Claude Max plan.

What metadata to check:

In session transcripts, check the assistant response usage.cache_creation metadata for the prompt cache tier:

  • usage.cache_creation.ephemeral_1h_input_tokens
  • usage.cache_creation.ephemeral_5m_input_tokens

If 1-hour TTL is active, ephemeral_1h_input_tokens should be non-zero. If 5-minute TTL is active, ephemeral_5m_input_tokens should be non-zero.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.96

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

VS Code integrated terminal

Additional Information

No response

extent analysis

TL;DR

The issue can likely be resolved by modifying the logic that determines the prompt cache TTL to ensure it is independent of telemetry settings.

Guidance

  • Review the code that handles telemetry settings and prompt cache TTL selection to identify where the dependency is introduced.
  • Verify that the DISABLE_TELEMETRY and CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC environment variables are not directly influencing the TTL selection logic.
  • Check the documentation for the Anthropic API and Claude Code to see if there are any known issues or workarounds related to telemetry and cache TTL.
  • Test the scenario with different combinations of telemetry settings and cache TTLs to confirm the issue is consistently reproducible.

Example

No specific code snippet can be provided without more information about the underlying implementation, but the fix will likely involve modifying the conditional logic that determines the prompt cache TTL.

Notes

The issue may be specific to the Opus Claude model or the Anthropic API, and further investigation is needed to determine the root cause. Additionally, the fact that the issue may not be reproducible with certain settings (e.g., ENABLE_PROMPT_CACHING_1H_BEDROCK=1) suggests that there may be multiple factors at play.

Recommendation

Apply a workaround by modifying the local configuration or code to decouple the telemetry settings from the prompt cache TTL selection logic, as the root cause of the issue is not immediately clear and may require further investigation.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING