Spawn Agent Tool
spawn_agent_tool · Nodes · AI
Creates a tool that starts an agent workflow.
Spawn Agent Tool#
Creates a configurable sub-agent tool that can be connected to AI agent nodes. When the parent agent calls this tool, it spawns a new agent loop with a fresh context window, configured system prompt, and restricted tool access.
When to Use#
- Task delegation - Breaking complex workflows into specialized sub-tasks handled by domain-specific agents
- Tool selection - Limiting a sub-agent to explicitly configured capabilities for its task
- Context isolation - Running agents with clean context to prevent context pollution
- Multi-domain workflows - Chaining together specialized agents (researcher → analyst → writer)
- Cost optimization - Using cheaper models for simple sub-tasks, expensive models only where needed
- Parallel processing - Delegating independent tasks to run concurrently (when called multiple times)
How It Works#
The Spawn Agent Tool node configures a sub-agent with its own system prompt and tool set. When connected to an AI Agent node, the parent agent can call spawn_agent with a task description. The sub-agent:
- Starts with a fresh context window (no parent conversation history)
- Uses the configured system prompt (not inherited from parent)
- Has access only to configured General tools (not inherited parent tools)
- Runs to completion with a configurable turn limit
- Returns only the final response to the parent agent
Configuration#
Required Fields#
- System Prompt - Defines the sub-agent's behavior and role
- Example:
"You are a code reviewer. Analyze the provided code for bugs and style issues." - Example:
"You are a research assistant. Search for information and summarize findings." - This is separate from the parent agent's system prompt
- Example:
Agent Base#
- Agent Base (
agent_base) - Boolean, default off
Agent Base sends working principles beneath the sub-agent's system prompt: finish the whole task, keep to the requested scope, adjust after a failed tool call instead of repeating it, and report only what it observed. The system prompt wins where the two differ. It applies to the sub-agent only, independent of the calling node's own agent_base setting. It is off by default, and a workflow saved without the field loads with it off.
Execution Limits#
Max Turns - Maximum number of agent loops (default: 10, range: 1-50)
- Prevents runaway sub-agents
- Each tool call + response counts as one turn
- Increase for complex multi-step tasks
Temperature - Optional creativity vs consistency, 0.0-2.0; off uses the model's own value
- 0.0-0.3: Deterministic, factual tasks
- 0.5-0.7: Balanced
- 0.8+: Creative tasks
Top-p - Optional nucleus sampling, 0.0-1.0; off uses the model's own value
Top-k - Optional top-k sampling limit, 1 or more; off uses the model's own value
Model - Optional AI connection and model for the sub-agent
- Leave unset to use the parent agent's model
- Use cheaper models for simple tasks to save costs
Tool Name - Custom name for this tool (default: "spawn_agent")
- Name visible to the parent AI when deciding which tool to call
Inputs#
tools- Tool configurations to make available to the sub-agent- Connect output from a Tool Provider node or other tool sources
- Sub-agent can ONLY use these tools
- Can be empty (sub-agent has no tool access)
- Must be compatible with
general; Workflow/Yield tools are rejected, even when the parent runs inside a workflow
Outputs#
- tool - A tool that can be connected to AI Agent nodes
- Connect this to the
toolsinput socket of an AI Agent or AI Conversation node - The parent agent will see
spawn_agentas an available tool
- Connect this to the
Wiring Pattern#
Basic Pattern: Single Sub-Agent#
[Trigger] → [Tool Provider] → (tools) → [AI Agent]
↗
[Spawn Agent Tool Node] → (tool) ──────┘
Example:
- Tool Provider gives general tools (search, knowledge)
- Spawn Agent Tool creates a "Code Reviewer" with only document tools
- AI Agent can delegate code review tasks: "Review this code for bugs"
Advanced Pattern: Multiple Specialists#
┌→ [Spawn Agent: Researcher] → (tool) ─┐
[Trigger] → [AI Agent] →┼→ [Spawn Agent: Analyst] → (tool) ─┤→ (tools)
└→ [Spawn Agent: Writer] → (tool) ──────┘
Example:
- Main AI Agent coordinates the workflow
- Researcher agent has web search + knowledge tools
- Analyst agent has calculation + chart tools
- Writer agent has document creation tools
- Main agent delegates to appropriate specialist based on the task
Usage Example#
Configuration#
{
"system_prompt": "You are a focused research assistant. Search for the requested information and provide a concise summary with sources.",
"max_turns": 5,
"temperature": 0.3,
"model": "glm-5.1",
"tool_name": "research_agent"
}
Parent Agent Call#
When the parent agent calls spawn_agent:
{
"task": "Research the latest developments in quantum computing. Focus on breakthroughs in 2024."
}
Sub-Agent Behavior#
- Receives only the task as user input
- Has access to tools provided via the
toolsinput socket only - Uses the configured model
- Runs up to 5 turns searching and synthesizing
- Returns final summary to parent agent
Important Behaviors#
Context Isolation#
- Sub-agents start with fresh context
- No access to parent conversation history
- Parent must include all necessary context in the
taskparameter - This prevents context pollution and keeps sub-agents focused
Tool Restrictions#
- Sub-agents can only use explicitly configured tools
- A surface is an execution expectation, not authorization. A child accepts only General tools; selecting a General group does not enable every registered tool or bypass workspace access.
Model and Auth#
- Spawn Agent Tool selects an optional connection-local sub-agent model override
- The parent AI agent connection supplies credentials/auth
- Leave model unset to inherit the parent model
- Use
list_modelsto select a model id from the parent agent connection'smodels[] - Useful for cost optimization (cheaper models for simple tasks)
Error Handling#
Common errors:
- Max turns exceeded - Increase
max_turnsfor complex tasks - Timeout - Sub-agent took too long (120s limit)
- Tool execution failed - One of the configured tools failed
Best Practices#
Design focused sub-agents#
Good:
System: "You are a code reviewer. Check for security vulnerabilities."
Tools: [LibraryGetTool]
Bad:
System: "You are a helpful assistant." // Too generic
Tools: [All tools] // No scoping benefit
Include context in task#
Good:
{
"task": "Analyze this Python function for bugs:\n\ndef calculate(x, y):\n return x / y"
}
Bad:
{
"task": "Check for bugs" // No context about what to check
}
Use appropriate models#
- Simple tasks (summarization, extraction): Use cheaper models (Haiku, GPT-3.5)
- Complex reasoning: Use stronger models (Sonnet, GPT-4)
- Configure explicit models when cost matters
Set appropriate turn limits#
- Simple tasks: 3-5 turns
- Multi-step analysis: 10-15 turns
- Complex research: 20-30 turns
- Always set a limit to prevent runaway agents
Comparison with Related Nodes#
| Node | Use Case | Tool Access |
|---|---|---|
| Spawn Agent Tool | Delegate to specialized sub-agent | Restricted subset |
| Tool Provider | Give tools to current agent | All provided tools |
| Subworkflow Tool | Execute a workflow as a tool | Workflow-defined |
| AI Agent | Main reasoning agent | Configurable |
Related Nodes#
- AI Agent - Can use Spawn Agent Tool as one of its tools
- AI Conversation - Can also use Spawn Agent Tool
- Tool Provider - Used to select tools for the sub-agent
- Subworkflow Tool - Alternative for workflow-based delegation
Inputs
toolsOptional
Outputs
tool
Configuration
| Field | Type | Required | Description |
|---|---|---|---|
system_prompt | text_block | Yes | System prompt for the sub-agent |
agent_base | boolean | No | Put the Agent Base beneath the system prompt: working principles that finish the whole task, keep to its scope, adjust after a failed tool call instead of repeating it, and report only what was observed. The system prompt still wins where the two differ. |
max_turns | integer | No | Maximum number of turns for the sub-agent |
model | model | No | Optional AI connection and model for the spawned agent. Leave unset to use the parent agent's model. |
temperature | nullable<number> | No | Sampling temperature, sent only when enabled. Off uses the model's own temperature. |
top_p | nullable<number> | No | Nucleus sampling top-p, sent only when enabled. Off uses the model's own top-p. |
top_k | nullable<integer> | No | Top-k sampling limit, sent only when enabled. Off uses the model's own top-k. |
tool_name | string | No | Name the AI will see for this tool |
base_config | record | No | Shared node configuration. failure_mode decides what a failure of this node does to the workflow; leave it at the default stop unless the workflow handles the failure itself on the node's error output (route_to_error) or the node is a rare emergency kill switch (stop_workflow). |