You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature Request] Add context window management and conversation summarization support #1173
When using kagent with models that have limited context windows (e.g., gpt-4o-mini with 128k tokens), agents with many MCP tools can exceed the context limit, causing "Session terminated" errors.
Currently, kagent does not expose ADK's context management features through the Agent CRD.
Problem
With an agent configured with ~40+ MCP tools, the context quickly exceeds limits:
Each tool definition adds tokens to the context
Conversation history accumulates
No way to truncate, summarize, or manage context programmatically
Error observed:
context_length_exceeded: This model's maximum context length is 128000 tokens.
However, your messages resulted in 155XXX tokens.
i run 28 MCP servers in my daily setup, roughly 400 tools total. the token overhead from tool schemas alone is around 50k tokens before a single message is sent. the part nobody talks about is that context compression doesn't actually solve the root problem, it just delays it. tool definitions are injected on every request, they're not part of conversation history, so compaction of older events won't touch them. what actually worked for me was aggressive tool filtering at the agent config level, giving each subagent only the 5-8 tools it actually needs instead of the full set. went from constant context overflows to zero in about a week. the tradeoff is you need to think upfront about which tools each agent role requires, but that's a design problem not a runtime one. caching helps with the conversation side but the schema bloat is the real killer at 40+ tools.
Activity
Insomniac2904 commentedon Jan 11, 2026
hey @jeanlopezxyz , sorry i did not make a design doc . Would you like me to make short summary of the made changes?
ronbutbul commentedon Feb 17, 2026
any updates on that matter?
(compression and caching feature)
can not really work like this currently
im hitting token limit very quickly cause every prompt history is being added to the context
m13v commentedon Apr 15, 2026
i run 28 MCP servers in my daily setup, roughly 400 tools total. the token overhead from tool schemas alone is around 50k tokens before a single message is sent. the part nobody talks about is that context compression doesn't actually solve the root problem, it just delays it. tool definitions are injected on every request, they're not part of conversation history, so compaction of older events won't touch them. what actually worked for me was aggressive tool filtering at the agent config level, giving each subagent only the 5-8 tools it actually needs instead of the full set. went from constant context overflows to zero in about a week. the tradeoff is you need to think upfront about which tools each agent role requires, but that's a design problem not a runtime one. caching helps with the conversation side but the schema bloat is the real killer at 40+ tools.
danialkhatib commentedon May 23, 2026
any updates on that matter?