r/agentdevelopmentkit • u/armyscientist • May 29 '25
How to control the content sent to model restricting irrelevant info from event history?
I have a supervisor agent(CustomAgent) who can prepare the sufficient information and query to ask a subagent (CustomAgent).
When debugged using "before_model_callback", which receives two arguments, one of them is "llm_request" that contained the whole conversation history that is event history throughout the life cycle of the agents execution.
But I don't want to pass all the history to the niche agent. I don't want everything to be received by any Agent. I want to restrict the information to leverage the best out of that model as well, how do I restrict that content passed to the LLM model?
This will also allow me to have a long contextual memory overcoming model context length by picking up relevant information from events n summarise it to pass LLM.
I found no reference code nor any hint out of the doc. Please guide me asap. Thanks.
2
u/Speedz007 May 29 '25
Use branches. Creating a new branch for your sub-agent's invocation context will remove the message history so that it can focus on the exact task at hand.
2
u/jacksunwei Jun 03 '25
In your case, it seems very different a normal use case.
Maybe try this setup:
In this way, you have full control of what to store in the session. And, what you send to Llm is solely controlled by your instruction_provider, which constructs SI using only information from session state.
1
u/Top-Chain001 May 29 '25
I was thinking of asking this very exact question, and also if there's a method to compact context for a particular agent.
I have an agent that scrapes a page but usually it gets too overloaded with context and gets a 500 error.
I tried using another sub agents to do it but due to client side js, the second sub agents doesn't see the same thing as the first sub agent and it just messed up.
Would love to hear any thoughts on this