Uh oh!
There was an error while loading. Please reload this page.
fix(session): warn on cache busts - #40796
Open
zcxGGmu wants to merge 1 commit into
Open
Conversation
Contributor
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes#40790
Type of change
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?
bun test test/session/compaction.test.ts --test-name-pattern "flags likely Anthropic cache busts|does not flag ordinary cache hits" --timeout 30000failed becauseSessionNs.cacheBustWarningdid not exist.bun test test/session/compaction.test.ts --test-name-pattern "SessionNs.getUsage" --timeout 45000— 17 pass.bun run typecheckbun run lint packages/opencode/src/session/session.ts packages/opencode/src/session/processor.ts packages/opencode/test/session/compaction.test.tsgit diff --checkNotes: two broader session tests fail the same way on a clean
devbaseline in this Windows checkout:stops quickly when aborted during retry backoffretry OpenAI-compatible midstream server errorsScreenshots / recordings
Not a UI change.
Checklist