Skip to content

feat(tools): add SubagentToolset for bounded parallel subagent fan-out - #8513

Open
me-her wants to merge 1 commit into
google:mainfrom
me-her:feat/subagent-fanout-toolset
Open

me-her wants to merge 1 commit into
google:mainfrom
me-her:feat/subagent-fanout-toolset

Conversation

@me-her

@me-her me-her commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds SubagentToolset (google.adk.tools.SubagentToolset), a BaseToolset that equips a coordinator LlmAgent with a run_subagents tool 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:

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 Runner wrappers.

Shipping a clean, batteries-included SubagentToolset strengthens 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)

  • Zero core runtime changes: Built purely on top of BaseToolset, LlmAgent, and Runner (unlike larger runtime rewrites).
  • Bounded concurrency & ordering: Caps concurrent workers with max_workers (asyncio.Semaphore), caps batch size with max_tasks_per_call, and preserves input order in the returned results.
  • Context & error isolation: Each worker runs in an isolated nested Runner (InMemorySessionService, ForwardingArtifactService, StreamingMode.NONE, max_llm_calls_per_worker, worker_timeout_s, and asyncio.gather(..., return_exceptions=True)) so one failed or timed-out worker never crashes sibling workers.
  • Recursion guard: Tracks temp:_adk_subagent_depth against max_depth (default 1), strips SubagentToolset from worker tools, and omits run_subagents at depth >= max_depth.
  • Plugin safety: include_plugins=False by default so interactive UI plugins cannot block headless parallel workers.
  • Optional tool profiles: Supports tool_profiles so the coordinator can select a curated toolset per task via profile.

Testing Plan

  • Added tests/unittests/tools/test_subagent_toolset.py (8 tests covering constructor validation, max_depth recursion guard, bounded concurrency + order preservation, error/timeout isolation, tool_profiles + recursion stripping, input validation, and end-to-end Runner fan-out — all 8 passing).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant