Clarify and Control Conversational History for LLM Token Optimization
It's unclear how the ADK Runner uses session.events and session.state to construct the contents[] array for LLM prompts. This makes it difficult to manage and predict token consumption from conversational history, leading to potentially high costs and exceeding context limits as conversations grow.
We need to understand if/how the ADK inherently manages this token growth from history, or how developers are expected to.
Describe the solution you'd like:
- Documentation: Clearly document the default mechanism by which the ADK Runner incorporates session.events and session.state into the LLM prompt's contents[], especially regarding history length and token count.
- Control/Configuration: Provide clear configuration options or developer hooks to manage how much and what parts of the session history are included in LLM prompts, enabling strategies like summarization or windowing to optimize token usage.
It's unclear how the ADK Runner uses session.events and session.state to construct the contents[] array for LLM prompts. This makes it difficult to manage and predict token consumption from conversational history, leading to potentially high costs and exceeding context limits as conversations grow.
We need to understand if/how the ADK inherently manages this token growth from history, or how developers are expected to.
Describe the solution you'd like:
- Documentation: Clearly document the default mechanism by which the ADK Runner incorporates session.events and session.state into the LLM prompt's contents[], especially regarding history length and token count.
- Control/Configuration: Provide clear configuration options or developer hooks to manage how much and what parts of the session history are included in LLM prompts, enabling strategies like summarization or windowing to optimize token usage.
It is not well documented, but you can use callbacks for summarization and windowing
Thanks for raising this. We are looking into this.
I created 8 subagents. How Can I Control output token limit of each agent
Hi @borso271 and thanks to everyone who participated in this thread.
We're currently doing some housekeeping on our issue tracker. Given the rapid pace of development and the number of updates since this was last active, there's a good chance this issue has been resolved in a newer version. To help us keep our backlog focused on current issues, we are closing this as stale.
If you're still facing this problem, could you please update to the very latest version of the library and confirm the issue still exists? If it does, please comment here, and we will be happy to reopen this issue and investigate further.
Thanks for your contribution and understanding!