Skip to content

[Question] Best way of passing parameters between root LLM agent and sequential agent-as-a-tool #2812

@amisev

Description

@amisev

Hello ADK Team,

I'm looking for guidance on the best practice for passing initial parameters from a root LLMAgent to a SequentialAgent that is being used as a tool.

  1. My Setup

My setup involves a root LLMAgent that uses AgentTool to delegate tasks to a multi-step SequentialAgent.

# A multi-step agent that will be used as a tool """
foo_tool_agent = SequentialAgent(
    name="FooTool",
    sub_agents=[...], # Contains one or more BaseAgents
    description="A tool that performs a multi-step task.",
)

# The root agent that calls the tool
bar_assistant_agent = Agent(
    name="BarAssistant",
    model="gemini-2.5-flash",
    tools=[AgentTool(agent=foo_tool_agent)],
)
  1. Observed Data Flow

When the BarAssistant's LLM generates a tool call for my SequentialAgent, the function call looks like this:

"function_call": {
    "name": "FooTool",
    "args": { "request": "{\"param1\": \"valueA\", \"param2\": 123}" }
}

By inspecting the AgentTool's source code, I can see that it takes the string value from args['request'] and wraps it in a types.Content object. This Content object is then passed as the new_message to the Runner that executes the foo_tool_agent.

  1. The Question: How to Read the Arguments?

My question is: What is the official or most idiomatic way for the first sub-agent inside FooTool to access this initial request string ("{"param1": "valueA", "param2": 123}")?

I see a few potential ways to access this data from the ctx object within my sub-agent's _run_async_impl method:

A) From ctx.user_content: Should I access the raw message directly?

request_str = ctx.user_content.parts[0].text
params = json.loads(request_str)

B) From the Session Events List: Should I parse the last event from the session history?

last_event = ctx.session.events[-1]
request_str = last_event.content.parts[0].text
params = json.loads(request_str)

I would appreciate any clarity on the recommended approach for this common agent-as-a-tool pattern. Thank you!

Metadata

Metadata

Assignees

Labels

core[Component] This issue is related to the core interface and implementation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions