-
Notifications
You must be signed in to change notification settings - Fork 119
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)
|
@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.
|
|
||
| #### 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?
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.
@benbrandt Great point on the naming! You're right that "context" is a bit awkward here.
I think we're aligned on the core idea - distinguishing between turn usage vs session usage:
-
Turn usage (in
PromptResponse): Token breakdown for that specific turn - input, output, thought, cached tokens. This is the "what just happened" data. -
Session usage (via
session/update): Cumulative state - total tokens consumed, context window utilization, cost. This is the "where are we now" data that agents push when available.
The session/update notification could use sessionUpdate: "usage_update" instead of "context_update" to better reflect this. The payload would still include context window info (used, size) alongside cumulative cost, but framing it as "usage" makes more conceptual sense.
Would renaming to sessionUpdate: "usage_update" address the naming concern? Happy to update the RFD if that direction works.
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.
Yeah I think we're on the same page here 👍🏻 thanks!
…ontext update fields
Proposes standardized tracking of token usage, cost estimation, and context window status across ACP implementations.