Emit usage updates from Claude stream events#506
Open
Mng-dev-ai wants to merge 2 commits intoagentclientprotocol:mainfrom
Open
Emit usage updates from Claude stream events#506Mng-dev-ai wants to merge 2 commits intoagentclientprotocol:mainfrom
Mng-dev-ai wants to merge 2 commits intoagentclientprotocol:mainfrom
Conversation
ed5223a to
70a7a4c
Compare
70a7a4c to
e656cc4
Compare
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.
Summary
usage_updatenotifications from top-level Claudestream_eventmessage usagemessage_startandmessage_deltaso partial deltas still produce a complete totalresult-path update as the final exact/cost-bearing usage eventWhy
Claude SDK stream events already carry incremental usage on
message_delta, butclaude-agent-acpcurrently ignores that path and only emitsusage_updatefrom the finalresult. This makes usage appear stale until the turn ends in ACP clients that expect live context usage updates.Verification
npm run buildusage_updatenotifications emitted before the final result-path usage updatePatched local smoke-test output included this sequence:
usage_update used=20973 size=200000agent_message_chunk text=TEST_OKusage_update used=20989 size=200000usage_update used=20989 size=1000000 cost=0.1314875