Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
SubagentToolset(google.adk.tools.SubagentToolset), aBaseToolsetthat equips a coordinatorLlmAgentwith arun_subagentstool to dynamically fan out ad-hoc subagent tasks in parallel with isolated context windows, bounded concurrency, per-worker timeouts, and built-in recursion guards.Why ADK Needs This Now
Modern agentic systems (Codex, Antigravity, Claude Code, etc.) rely on dynamic subagent fan-out as a core primitive: a coordinator model decomposes an open-ended task at runtime, spawns 2–N specialized workers in parallel with clean context windows, and synthesizes their results.
Today, ADK provides:
sub_agentsdefined at construction time,AgentToolwrappers, andparallel_worker=Truewithmax_parallel_workers(feat(workflow): support bounded parallel agent workers #7912) for fanning out a predefined node over an input list.What is still missing out of the box is an LLM-callable fan-out tool so a coordinator agent can invent worker slices on the fly (e.g., parallel research, multi-section document/slide generation, multi-file analysis) without polluting its own context window or requiring every developer to hand-roll nested
Runnerwrappers.Shipping a clean, batteries-included
SubagentToolsetstrengthens Google's ADK ecosystem immediately and provides a lean, low-risk foundation that can later evolve toward full swarm capabilities (persistent worker handles, steering, and peer coordination, as discussed in #7642).Design Highlights (Lean & Additive)
BaseToolset,LlmAgent, andRunner(unlike larger runtime rewrites).max_workers(asyncio.Semaphore), caps batch size withmax_tasks_per_call, and preserves input order in the returnedresults.Runner(InMemorySessionService,ForwardingArtifactService,StreamingMode.NONE,max_llm_calls_per_worker,worker_timeout_s, andasyncio.gather(..., return_exceptions=True)) so one failed or timed-out worker never crashes sibling workers.temp:_adk_subagent_depthagainstmax_depth(default1), stripsSubagentToolsetfrom worker tools, and omitsrun_subagentsatdepth >= max_depth.include_plugins=Falseby default so interactive UI plugins cannot block headless parallel workers.tool_profilesso the coordinator can select a curated toolset per task viaprofile.Testing Plan
tests/unittests/tools/test_subagent_toolset.py(8 tests covering constructor validation,max_depthrecursion guard, bounded concurrency + order preservation, error/timeout isolation,tool_profiles+ recursion stripping, input validation, and end-to-endRunnerfan-out — all 8 passing).