-
Notifications
You must be signed in to change notification settings - Fork 589
Description
Problem Statement
Currently strands has accumulated token usage which keeps track of all the tokens used in the current turn. However, it is often useful to know what the token size of the current agent context (agent.messages) is. This value can be used for proactive conversation management (current tokens > threshold) or just to expose to a downstream user.
Today one option is to use count_tokens provided by bedrock but this tends to eat up TPM limits pretty fast as well as adding to the latency of the over-all turn.
Proposed Solution
Add another tracked metric in event logs that keeps track of current agent context token size.
Use Case
For proactive memory/context management (to trigger summarization) and to expose this information to a downstream user.
Alternatives Solutions
Today one option is to use count_tokens provided by bedrock but this tends to eat up TPM limits pretty fast as well as adding to the latency of the over-all turn.
Additional Context
No response