Managed Agent — Single-Turn Sub-Agent (Tool) Flow
For setup, authentication, backends, and background on
ManagedAgent, see the ManagedAgent guide.
Overview
This sample shows a local LlmAgent coordinator that calls two server-backed
ManagedAgent specialists as single-turn sub-agents (mode='single_turn').
ADK auto-exposes each single-turn sub-agent to the coordinator as an inline tool.
The coordinator calls a specialist, receives the result, and may call several
specialists in one turn before composing the final answer itself.
A single-turn sub-agent's internal events (e.g. tool calls) are preserved in the shared session history.
The two specialists are:
managed_search_agent— aManagedAgentwith the server-sidegoogle_searchtool, for questions that require web search results.managed_code_execution_agent— aManagedAgentwith server-side code execution, for questions that require computation.
Note
Each
ManagedAgentsets adescription; ADK builds the tool declaration from it, so a missing description makes tool selection unreliable.
Note
Each single-turn call is stateless and isolated, so the coordinator should pass a self-contained request to each specialist (do not rely on a specialist remembering a previous call).
Sample Inputs
-
What was the score of the most recent FIFA World Cup final?Requires web search results — the coordinator calls
managed_search_agent. -
What's the 30th Fibonacci number? Use code.Requires computation — the coordinator calls
managed_code_execution_agent(answer: 832040). -
Look up the height of Mount Everest in meters, then use code to convert it to feet.The coordinator calls both specialists in one turn (search for the height, then code to multiply by 3.28084) and composes a single answer.
Graph
graph TD
Coordinator[LlmAgent coordinator] -->|single_turn tool call| Search[managed_search_agent]
Coordinator -->|single_turn tool call| Code[managed_code_execution_agent]
How To
- Coordinator: an
LlmAgentwith a non-emptysub_agentslist of single-turn specialists. - Specialists: each is a
ManagedAgentwithmode='single_turn', anagent_id, anenvironmentspec, server-sidetools, and adescriptionused for tool selection. - Delegation: ADK exposes each single-turn specialist as an inline tool; the coordinator calls it, gets the result, and keeps control of the turn.