Skip to content

Return token usage in ACP prompt responses#283

Open
ruixingshi wants to merge 1 commit into
zed-industries:mainfrom
ruixingshi:fix/respones-usage
Open

Return token usage in ACP prompt responses#283
ruixingshi wants to merge 1 commit into
zed-industries:mainfrom
ruixingshi:fix/respones-usage

Conversation

@ruixingshi
Copy link
Copy Markdown

Capture Codex token count events during a prompt turn and map the final turn delta into PromptResponse.usage. Preserve existing context-window UsageUpdate notifications while returning ACP usage to clients.

Capture Codex token count events during a prompt turn and map the final turn delta into PromptResponse.usage. Preserve existing context-window UsageUpdate notifications while returning ACP usage to clients.
@ruixingshi
Copy link
Copy Markdown
Author

Related issue: #282

Copy link
Copy Markdown

phplego commented May 16, 2026

Thanks for opening this. I think this is an important PR for ACP clients, because it fills the missing PromptResponse.usage path and makes Codex ACP much closer to the usage telemetry that Codex CLI already exposes.

There is also a related user-facing need here: editor clients should be able to show context-window pressure, e.g. Context 37% used (74k / 200k), so users know when they are approaching compaction territory. UsageUpdate.used / UsageUpdate.size already provide the right protocol shape for that, while this PR covers the final per-turn response usage.

If the maintainers would prefer to keep this PR narrowly focused, I would be happy to help with a smaller follow-up PR that only adjusts UsageUpdate.used to report cumulative context-window usage and adds a targeted regression test, leaving the broader PromptResponse.usage work here.

@ruixingshi
Copy link
Copy Markdown
Author

@benbrandt Sorry for the direct ping — could you take a look at this PR when you have a chance?

This is fixing a real problem for my ACP client. The final token usage for a prompt turn isn’t currently making it into PromptResponse.usage, and this PR adds that without changing the existing UsageUpdate behavior.

Do you think this approach looks OK to merge, or would you prefer a different solution? I’m happy to adjust it however you think is best.

@phplego Thanks for the comment! I think what you’re asking for is useful too, but it feels like a related follow-up rather than the same issue. If this PR can get merged first, I’d be happy to help with the context-window pressure part afterward.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants