AI SummaryConverts deepagents' single `task` tool into individual `AgentTool` instances for cleaner sub-agent delegation in adk-deepagents. Developers building hierarchical multi-agent systems benefit from this more modular approach to agent composition.
Install
Copy this and paste it into Claude Code, Cursor, or any AI assistant:
I want to set up the "Sub-Agent Delegation" agent in my project. Please run this command in my terminal: # Add AGENTS.md to your project root curl --retry 3 --retry-delay 2 --retry-all-errors -o AGENTS.md "https://raw.githubusercontent.com/manojlds/adk-deepagents/main/docs/subagents.md" Then explain what the agent does and how to invoke it.
Description
In deepagents, a single `task` tool routes work to sub-agents by name. In adk-deepagents, each sub-agent becomes its own [`AgentTool`](https://google.github.io/adk-python/) instance, so the parent agent calls them like any other tool. The `build_subagent_tools` function in `adk_deepagents.tools.task` converts a list of `SubAgentSpec` dicts (or pre-built `LlmAgent` objects) into `AgentTool` instances that are added to the parent agent's tool list.
Overview
In deepagents, a single task tool routes work to sub-agents by name. In adk-deepagents, each sub-agent becomes its own AgentTool instance, so the parent agent calls them like any other tool. The build_subagent_tools function in adk_deepagents.tools.task converts a list of SubAgentSpec dicts (or pre-built LlmAgent objects) into AgentTool instances that are added to the parent agent's tool list. For the dynamic task implementation (delegation_mode="dynamic") and runtime details (task_id, state keys, registries, timeout/error behavior), see Task System Internals.
build_subagent_tools
The build_subagent_tools function converts specs into AgentTool instances: `python from adk_deepagents.tools.task import build_subagent_tools tools = build_subagent_tools( subagents=[spec1, spec2], default_model="gemini-2.5-flash", default_tools=core_tools, include_general_purpose=True, skills_config=None, ) ` Parameters: | Parameter | Description | |---|---| | subagents | List of SubAgentSpec dicts or pre-built LlmAgent instances | | default_model | Model to use when a spec doesn't specify one | | default_tools | Default tools given to sub-agents that don't specify their own | | include_general_purpose | If True (default), prepend the general-purpose sub-agent | | skills_config | Optional SkillsConfig for sub-agents with skills set | Each spec becomes an LlmAgent wrapped in an AgentTool: `python sub_agent = LlmAgent( name=_sanitize_agent_name(spec["name"]), model=spec.get("model", default_model), instruction=spec.get("system_prompt", DEFAULT_SUBAGENT_PROMPT), description=spec["description"], tools=sub_tools, before_tool_callback=before_tool_cb, ) AgentTool(agent=sub_agent) `
Sub-Agent with Custom Tools
`python from adk_deepagents import SubAgentSpec, create_deep_agent def web_search(query: str) -> str: """Search the web for information.""" # Your search implementation return f"Results for: {query}" researcher = SubAgentSpec( name="researcher", description="Research agent with web search capability.", tools=[web_search], # Only has web_search, not the default filesystem tools ) agent = create_deep_agent( subagents=[researcher], ) `
SubAgentSpec
SubAgentSpec is a TypedDict that describes a sub-agent: | Field | Type | Required | Description | |---|---|---|---| | name | str | ✅ | Unique name for the sub-agent | | description | str | ✅ | What the sub-agent does (shown to the parent agent) | | system_prompt | str | ❌ | Custom system instruction for the sub-agent | | tools | Sequence[Callable] | ❌ | Custom tools; defaults to the parent's core tools | | model | str | ❌ | Model string; defaults to the parent agent's model | | skills | list[str] | ❌ | Directories to discover Agent Skills from | | interrupt_on | dict[str, bool] | ❌ | Tool names requiring human approval | `python from adk_deepagents import SubAgentSpec spec = SubAgentSpec( name="researcher", description="Research agent for gathering information on topics.", system_prompt="You are a research assistant. Gather relevant information.", model="gemini-2.5-pro", ) `
Discussion
Health Signals
My Fox Den
Community Rating
Sign in to rate this booster