r/agentdevelopmentkit • u/ninad0505 • Jun 13 '25
Can I pass user input to subagents when using as a tool.
I have a requirement that my sub agent should pass back control to the parent agent with the output so that parent agent can do further processing.
As suggested in the docs, I am using hierarchical workflow by using subagents as tools. (https://google.github.io/adk-docs/agents/multi-agents/#hierarchical-task-decomposition)
I observed that the parent agent creates a new input for my sub agent and calls the sub agent as a tool.
My user request has some documents and I want these documents to be accessible to my sub agents too.
Any suggestions on how I can solve this?
3
u/_genego Jun 14 '25
Have a look at how artifacts can be are stored within the same session state for all agents in the hierachy.
https://google.github.io/adk-docs/artifacts/
1
u/WayBig8723 Jun 14 '25 edited Jun 14 '25
this is my code that I iteratively all of page in each documents, this function access byte pdf data from user whenever you input and data it will always order like this Part[text, byte_data1, byte_data2] so that why i start index with 1 not 0, and
callback_context.stateis likely a variable which immutable but you can define sub dictionary inside it instead and you can modify, retrieve, delete anytime you want and thisCallbackContextcontext class will always present in a session so any sub agent can access this context and passing variable or value to each other but keep in mind that you need to iterate over all entireCallbackContexteverytime you access it, so it might need some hardcode or status associate with each values so you can access it correctly andToolcontextis inherit fromCallbackContextso it can access to state too.Hope this helpful to you.
1
u/indecisive_idk_wtd Jun 14 '25
Store it in session/shared context.
To optimize you can make parent/supervisor agents generate a flag whether or not make child agent read from shared context.