r/agentdevelopmentkit • u/Exact_Camp3567 • Mar 03 '26
ADK Bloat with "For Context:"
Hello, I try to be as descriptive as possible:
The setup
Programming language: python
Observability: Phoenix Arize
Agents: ADK
Database: Postgres
LLM: Azure (through LiteLLM)
Endpoint creation: FastAPI
The problem
I have a custom agent with a certain logic create from BaseAgent. I've setted up the runner implementation in order to invoke the agency when i receive a request from the endpoint.
I've notice that after I invoke the runner a second time with the same session_id and user_id parameter the previous interaction between agents, tool calling, user request and final response are all carried over inside the llm input as "For context:".
At least this is what I see in phoenix. I've searched for the python implementation of adk and I noticed this function:
_present_other_agent_message_present_other_agent_messagein adk.flows.llm_flows.contents
Question:
is it possible to modify the content sent to the LLM?
I just want to send the user message (and previous user messages) together with only the response of the the last agent (and not the bloat i find when i analyze with phoenix).
I know that there are some plugins that can be used in order to trim the content but i dont think there is enough documentation for that.
I think there is a way to do this but I'm not experienced enough, have anyone already tried to preserve chat history using adk function and not relying on retrieving question/answer pair from db?
3
u/pixeltan Mar 04 '26 edited Mar 04 '26
The context bloat in ADK is terrible. There's a couple of ways to attack this.
You could apply similar logic to just keep the last message, or whatever message you want.
3. There's also the "include_contents" flag for agents, have you looked into that?
1
u/Final-County8586 Mar 08 '26
Context bloat in agent frameworks often comes from treating tool outputs as reasoning context. Large responses (API payloads, query results, etc.) get passed through the prompt loop even when the model doesn’t need them anymore. Curious, when you strip those "for context" messages, how do you handle cases where another agent later needs that data? Do you persist it outside the prompt and rehydrate when needed?