-
Notifications
You must be signed in to change notification settings - Fork 114
docs(rfd): Add session usage and context status RFD #316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
docs(rfd): Add session usage and context status RFD #316
Conversation
Proposes standardized tracking of token usage, cost estimation, and context window status across ACP implementations. - Token usage reported in PromptResponse (per-turn data) - Context window and cost reported in session/status (session state)
| "percentage": 26.5, | ||
| "remaining": 147000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these two fields needed, they are fully derivable from size and used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They’re redundant mathematically, but they carry the agent’s own calculation/rounding and simplify client work
| - `percentage` (number, required) - Percentage used (0-100) | ||
| - `remaining` (number, required) - Tokens remaining |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto on the derived fields from size and used are these fields needed
|
|
||
| ### Design Principles | ||
|
|
||
| 1. **Separation of concerns** - Token usage is per-turn data, context window and cost are session state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how will this work with subagent "tools" that aren't performing full turns but are actively updating token usage frequently
|
@josevalim @SteffenDE I'd love to get your input on this one since you were looking into this a bit |
|
We like the idea and we definitely want to have a way to do this in ACP! For us, the most important part is the current usage (in percent). Including a The PR proposes a new |
|
@SteffenDE Thanks a lot for the detailed explanation and context 🙏 If this matches what you had in mind, I can adjust the RFD in that direction. |
|
@ahmedhesham6 yes! I'd wait before changing things though, since I'm not a maintainer here and basically just stating my opinion :D |
|
What do you think @benbrandt? |
|
Yeah I think something simple to start would be great. As @SteffenDE mentioned, support for this will likely vary wildly (and we've also seen mixed support of even these basic metrics within the same agent lol) I think we should let this be driven by the agent, as they will likely get the information from the provider and may forward it, but might not hold on to it. Requiring them to have the data at all points might be too much... So I'd opt for a simple way to report the basic information we feel we need, and go from there |
…cations Refines the tracking of context window and cost information by transitioning from `session/status` requests to `session/update` notifications. This change allows agents to proactively push updates, enhancing flexibility and real-time data availability for clients. The `cost` field is now optional, and the `remaining` field has been removed, as clients can compute it from `size` and `used`. Updated documentation to reflect these changes and provide clearer usage patterns.
| - `total_tokens` (number, required) - Sum of all token types across session | ||
| - `input_tokens` (number, required) - Total input tokens across all turns | ||
| - `output_tokens` (number, required) - Total output tokens across all turns | ||
| - `reasoning_tokens` (number, optional) - Total reasoning tokens (for o1/o3 models) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since in ACP we usually refer to this as thought I wonder if we could align that?
|
|
||
| - `used` (number, required) - Tokens currently in context | ||
| - `size` (number, required) - Total context window size in tokens | ||
| - `percentage` (number, required) - Percentage used (0-100) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we send this just to save a calculation on the client? since we allow them to calculate remaining, maybe we let them do this too?
|
|
||
| #### Cost Fields (optional) | ||
|
|
||
| - `cost` (object, optional) - Cumulative session cost |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
naming nitpick: it seems weird that this is part of a "context" update.
I wonder if all of this is just usage from a conceptual point of view?
And roughly the same data can be sent at the end of the turn, with mid-turn updates? So kind of merge these?
It seems you want to distinguish between turn usage vs total usage. Which makes sense, but I wonder if we can distinguish then between turn vs session usage?
| - Agent knows exact context window size (varies by model) | ||
| - Agent knows how it counts tokens (different tokenizers) | ||
| - Agent knows about special tokens, system messages, etc. | ||
| - Client can still recalculate if needed (all raw data provided) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont' really understand these arguments... Unless percentage will somehow be different than used / total (which would be weird) I feel the agent gets all of this by controlling the token counts already
Proposes standardized tracking of token usage, cost estimation, and context window status across ACP implementations.