Overview
Import path:from veadk.tools.builtin_tools.create_agent import CreateAgentToolset
CreateAgentToolset is a built-in toolset that lets a main agent collect available resources at runtime, create one or more sub-agents on demand, and transfer control to a chosen sub-agent through the Google ADK transfer_to_agent event. The sub-agent continues in the same session context and produces the final answer.
The toolset exposes two tools:
Resources returned by
collect_resources are candidates only and are not mounted automatically. The main agent must explicitly include each resource ref it wants to use in the resources list of every LLM node; when relevant skills are present in the catalog, at least one must be bound.When to use
Use this toolset when:- A main agent needs to assemble sub-agents with specific skills, knowledge bases, or tools on demand, rather than fixing the sub-agent structure at development time.
- You need to hand off a task to a dynamically created sub-agent within the same session context, where the sub-agent produces the final answer directly.
- You need to match resources from the public Skill Hub, account Skill Spaces, knowledge bases, and built-in tools against a task.
Prerequisites
The public Skill Hub search is driven by keywords generated by the main agent from the task; no Space ID is required. Once AK/SK or STS credentials are configured, the AgentKit Skill Center automatically enumerates every Skill Space visible to the account.SKILL_SPACE_ID only narrows the search to a specific Space, with multiple IDs separated by commas. SKILL_HUB_SPACE_ID is retained for compatibility with legacy Skill Hub Spaces.
Usage
Add aCreateAgentToolset() instance to the Agent tools list. Describe the resource-collection, blueprint-design, and handoff flow in the agent instruction; the model decides at runtime when to call the two tools.
dynamic_agent_coordinator.py
Resource collection and matching
By defaultcollect_resources gathers resources from the following sources and unifies them into a candidate catalog with a ref:
The
collection_id returned after collection must be passed unchanged to the subsequent create_agents call to associate the resource snapshot.
Agent blueprints
Theagents argument of create_agents is a list of blueprints, each describing one independently constructed root agent:
Nodes inside a blueprint support the following types, with availability depending on the installed Google ADK version:
The
workflow node is available only on Google ADK 2.0.0 and above. On lower versions, the capability catalog returned by collect_resources indicates the supported node types, and create_agents omits workflow nodes.LLM node
The LLM node is the most common leaf node. Its fields are:Ad-hoc Python tools
The main agent can provide complete Python source in thepython_tools of an LLM node, exposed as tools callable by the sub-agent:
Parameters
Constructor parameters ofCreateAgentToolset:
Limitations
create_agentsmust run within an active agent invocation driven by aRunner, otherwise it cannot register sub-agents and complete the handoff.- Within a session, each
collect_resourcescall overwrites the previous resource snapshot, andcreate_agentsconsumes the matching snapshot, after which it is no longer valid. - Dynamically created sub-agents are registered in the agent tree of the current session and are not retained after the session ends.
python_toolsrun in the current process without sandbox isolation.