Skip to content

fix(session): warn on cache busts - #40796

Closed
zcxGGmu wants to merge 1 commit into
anomalyco:devfrom
zcxGGmu:cache-bust-warning
Closed

fix(session): warn on cache busts#40796
zcxGGmu wants to merge 1 commit into
anomalyco:devfrom
zcxGGmu:cache-bust-warning

Conversation

@zcxGGmu

@zcxGGmu zcxGGmu commented Aug 6, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #40790

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds a small diagnostic for likely Anthropic prompt-cache busts. When a completed step reports a large cache write with zero cache reads for an Anthropic/Claude model, the session processor now emits a warning with the session, model, finish reason, cache-write tokens, cache-read tokens, and cost.

This does not revive the previously rejected object-identity caching approach from #36852. It only makes the high-cost pattern reported in #40790 visible in logs so users and maintainers can confirm when it happens.

How did you verify your code works?

  • RED: bun test test/session/compaction.test.ts --test-name-pattern "flags likely Anthropic cache busts|does not flag ordinary cache hits" --timeout 30000 failed because SessionNs.cacheBustWarning did not exist.
  • GREEN: bun test test/session/compaction.test.ts --test-name-pattern "SessionNs.getUsage" --timeout 45000 — 17 pass.
  • bun run typecheck
  • bun run lint packages/opencode/src/session/session.ts packages/opencode/src/session/processor.ts packages/opencode/test/session/compaction.test.ts
  • git diff --check

Notes: two broader session tests fail the same way on a clean dev baseline in this Windows checkout:

  • stops quickly when aborted during retry backoff
  • retry OpenAI-compatible midstream server errors

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Production evidence: Anthropic cache bust bug causes $14.82 waste across 3 sessions (22.5% bust rate)

2 participants