Defend against ACP server reporting used > size#5
Merged
timvisher-dd merged 2 commits intomainfrom Mar 15, 2026
Merged
Conversation
Add comprehensive ERT tests for agent-shell-usage.el covering notification updates, context indicator scaling/colors, compaction replay, token saving, and number formatting. The ACP server has a bug where model switches cause used to exceed size in session/update notifications. Rather than clamping, signal unreliable data: indicator shows ? with warning face, format shows (?) instead of a bogus percentage. A regression test replays real observed traffic from the Opus 1M -> Sonnet 200k switch scenario. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
timvisher-dd
added a commit
that referenced
this pull request
Mar 16, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
timvisher-dd
added a commit
that referenced
this pull request
Mar 17, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
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.
Closes xenodium#364
The ACP server (claude-agent-acp) has a bug where model switches cause
usedto exceedsizeinsession/updatenotifications. For example, switching from Opus 1M to Sonnet 200k dropssizeto 200000 whileusedkeeps growing past it (observed: 419574/200000 = 209.8%). This results in nonsensical context indicators and percentages e.g. (from a real session)While I intend to get a fix for this improper reporting into claude-agent-acp, agent-shell should be robust against it. To that end, when the garbage usage data is observed, the UI now signals unreliable data instead of showing nonsense:
?with warning face whenused > size(?)instead of a bogus percentageThis also adds comprehensive ERT test coverage for
agent-shell-usage.el: notification updates, indicator scaling/colors, compaction replay, token saving, and number formatting.For the
claude-agent-acpside of this see agentclientprotocol/claude-agent-acp#412Test plan