Fix Agent Mode context-window reporting#507
Open
BetaFold3 wants to merge 2 commits into
Open
Conversation
Resolve configured Claude and Codex context limits while keeping the canonical model maximum separate from the effective denominator. Attribute Claude modelUsage to the active model, preserve valid large usage readings, and avoid presenting unknown fallback windows as facts. Add focused resolver, lifecycle, usage, translator, and sidebar coverage.
Upstream added the MCPAskOracleWorktreeTests git-diff-artifact row independently after this branch had added it as a missing-row fix; the rebase merge kept both copies and CI's strict-ledger duplicate gate failed all app-test shards. Keep upstream's row, drop the duplicate.
c2a5aa2 to
3c4c9eb
Compare
Contributor
Author
|
This PR does not modify the failing test or Codemap implementation. Mind helping with the re-trigger? @baron |
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 free
to 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.
Fixes #506
Why
The context indicator could use three different denominators during one session:
Besides being confusing, this could produce incorrect percentages and silently discard valid usage readings above 200K.
This was especially visible with Codex GPT-5.5 and GPT-5.6: a fresh session could present the 200K internal fallback before runtime usage reported the actual window. GPT-5.5 was observed reporting approximately 258.4K after the first response. 353.4K in case of GPT 5.6.
What changed
config.toml.—instead of exposing the internal 200K fallback as fact.Bug found along the way
Claude result events may report usage for several models in the same session, including background Haiku work.
The translator previously selected the first positive
modelUsageentry from an unordered dictionary. A background 200K model could therefore replace the main model’s 1M window, causing the sidebar to report 200K after the first response.This change attributes usage to the tracked main model, handles normalized model variants deterministically, and resets attribution across live model switches and process respawns.
User-visible behavior
Validation
make dev-provider-test FILTER=ClaudeSDKNDJSONTranslatorTestsmake dev-test FILTER=AgentRuntimeSidebarViewModelTestsmake dev-test FILTER=ClaudeContextUsageEstimatorTestsmake dev-swift-build PRODUCT=RepoPromptmake dev-lint