feat(tools): Add AgentDispatcherToolset for runtime agents - #6592
Open
a2105z wants to merge 2 commits into
Open
Conversation
Static sub_agents and AgentTool cannot spawn persistent specialists mid-run. Add a sync-first toolset that dispatches agents into durable child sessions and supports follow-up messaging. Related to google#4759
Extend AgentDispatcherToolset with background/parallel runs, await and completion callbacks, allowlisted skills, and shared session-service persistence so specialists can continue while the orchestrator works. Related to google#4759
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.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Note: This issue is assigned for internal review. This is a community proposal for design feedback — happy to adjust or close if you’d rather keep the design internal.
Problem:
Static
sub_agentsmust be known at construct time, andAgentToolcreates a fresh in-memory session per call. Orchestrators need runtime specialists that can run in the background, in parallel, with persistent follow-ups and completion signaling.Solution:
AgentDispatcherToolsetexposes:dispatch_agent— create a runtimeLlmAgenton a persistent child session. Background by default (wait=false) so the orchestrator continues;wait=truefor sync. Supportstool_names+skill_namesfrom constructor allowlists/registry.get_agent_result— poll latest status/result.await_agent— wait for background completion (optional timeout).message_agent— follow-up on the same child session.Also:
on_completesync/async callbacksession_service(parent’s by default) + serializable registry undersession.state["_adk_agent_dispatcher"]for rebuild/follow-upRemaining bounds / non-goals
These are intentional for a reviewable first cut; calling them out so reviewers know what this does not claim:
Skills are named + allowlisted, not free-form paths.
Dispatched agents can only attach skills from
skill_allowlistand/or askill_registrylookup by name. The model cannot load arbitrary filesystem/GCS skill paths. That keeps the surface safer; broader skill discovery can be a follow-up if desired.Cross-process restart needs a durable session service.
Child sessions and the dispatcher registry are persisted through the configured
BaseSessionService. With in-memory services, state dies with the process. For true restart survival, use a durable backend (e.g. database / Vertex session service) shared by parent and children, and reconstruct the toolset with the same allowlists/model.Rebuild still requires the same toolset config.
After a process restart, follow-ups rebuild the child
Runnerfrom session-state metadata (instruction,mode,tool_names,skill_names, etc.). The new process must constructAgentDispatcherToolsetwith compatibletool_allowlist/skill_allowlist/skill_registry/ model so those names resolve.Completion signaling is callback + poll/await, not parent-LLM push mid-turn.
on_completenotifies application code; the orchestrator LLM observes completion viaget_agent_result/await_agenton a later turn. This does not inject a spontaneous model turn into the parent when a background child finishes.Not a replacement for Workflow
ctx.run_node.This targets chat-style orchestrators that want tool-driven spawn. Graph/Workflow dynamic nodes remain the right primitive for interrupt/resume-heavy workflows.
Testing Plan
Unit Tests:
pytest tests/unittests/tools/test_agent_dispatcher_toolset.py -v # 8 passedCoverage: wait/background/await, parallel dispatch, on_complete callback, persistent message follow-up, rebuild from session state, skill allowlist, unknown tool rejection.
Manual E2E:
Checklist
Additional context
RFC on issue: #4759 (comment)
cc @klateefa @wuliang229 — concrete API sketch for review, not a claim on assigned work.