Subworkflow Tool
subworkflow_tool · Nodes · AI
Exposes a workflow as a callable tool.
Subworkflow Tool#
Exposes a workflow as an AI-callable tool. When the AI calls this tool, it executes the configured workflow, delivering {"args": ..., "context": ...} to a Tool Input node in the target workflow. The tool's description and argument schema are declared by that Tool Input node, not here; this node supplies only the tool's name.
When to Use#
- Workflow-as-a-tool - Package complex multi-step logic as a reusable tool the AI can invoke
- Visual coding - Create custom tools using the workflow editor instead of writing code
- Encapsulation - Hide implementation details behind a clean interface
- Reusability - Share workflows as tools across different AI agents
- Parameter validation - The target's Tool Input node declares the argument schema and refuses arguments that do not conform
- Self-documenting - The target's Tool Input
descriptiontells the AI what the tool does and when to call it
Prefer Subworkflow Tool when workflow-owned deterministic logic should perform side effects: sending messages, deleting or moving files, editing tables, approvals, normalization, or multi-step business processes. Use direct integration tool packaging nodes for bounded reads/querying or explicitly granted simple actions.
How It Works#
The Subworkflow Tool node packages a workflow as a named tool that AI agents can call:
- Configuration - Select a target workflow and the Tool Input node the call starts at
- Interface definition - The target's Tool Input node declares the tool description and the argument JSON Schema; nothing on this node does
- Execution - When called, the workflow runs with
{"args": ..., "context": ...}delivered to its Tool Input node - Result - The target workflow's
workflow_outputvalue, set byset_workflow_output, is returned to the calling agent
ExecuteWorkflowTool is direct workflow dispatch when the agent already knows the workflow/start-node contract. Subworkflow Tool is curated workflow-as-tool packaging: it supplies the AI-facing name, and reads the description and parameter schema from the target.
Configuration#
Required Fields#
Workflow - The workflow to execute when the tool is called
- Only workflows containing a Tool Input node are offered: a workflow without one cannot be called as a tool
Trigger Node - The Tool Input node the invocation starts at
- Only Tool Input nodes are offered
- Its
descriptionbecomes this tool's description and itsargs_schemathis tool's parameter schema
Tool Name - Name the AI will see for this tool
- Example:
analyze_sentiment,fetch_customer_data - Use descriptive names that indicate the tool's purpose
- The AI uses this name to call the tool
- Example:
Optional Fields#
- Supply Context Into Tool (
supply_context) - Supplies this node's input data as context alongside the arguments supplied by agents, allowing passing mechanical workflow data, ids, or sensitive data without exposing it to the agent- Default
false, in which casecontextis delivered as{} - The model never sees or supplies this data
- Default
Inputs#
- input - Workflow dependency, and the invocation context when Supply Context Into Tool is on
- With
supply_contextoff, it only controls execution ordering/tool construction - The model still provides tool arguments at call time
- With
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 this as an available tool with the configured name
- Connect this to the
Wiring Pattern#
Basic Pattern: Simple Tool#
[Trigger] → [Tool Provider] → (tools) → [AI Agent]
↗
[Subworkflow Tool Node] → (tool) ─────┘
Example:
- Tool Provider gives general tools (search, knowledge)
- Subworkflow Tool creates a "Sentiment Analyzer" that wraps a sentiment analysis workflow
- AI Agent can call:
analyze_sentiment({"text": "This product is amazing!"})
Advanced Pattern: Workflow with Parameters#
Target Workflow (sentiment_analyzer):
[Tool Input] → (args) → [AI Agent: Analyze sentiment] → [Set Workflow Output]
Tool Input Node Configuration (the description is what the AI sees):
{
"description": "Analyzes text sentiment. Pass a 'text' parameter. Returns sentiment (positive/negative/neutral) and confidence score.",
"args_schema": {
"type": "object",
"properties": {
"text": { "type": "string", "description": "Text to analyze" }
},
"required": ["text"]
}
}
Subworkflow Tool Configuration:
- Workflow:
sentiment_analyzer - Trigger Node: the Tool Input node
- Tool Name:
analyze_sentiment
Usage Example#
Target Workflow Setup#
Create a workflow named customer_lookup with:
Tool Input Node (input):
- description: "Use this tool when you need to retrieve customer information. Pass either 'email' or 'customer_id'. Returns customer details or null if not found."
- args_schema: an object schema with optional
emailandcustomer_idstring properties
Query Table Node (query_customers):
- Queries the customers table with filters from input
Set Workflow Output (
set_workflow_output):- Returns query results to the caller
Subworkflow Tool Configuration#
{
"workflow_id": "customer_lookup",
"start_node": "input",
"tool_name": "get_customer",
"supply_context": false
}
AI Agent Usage#
When the AI needs customer information:
{
"tool": "get_customer",
"arguments": {
"email": "john@example.com"
}
}
The workflow executes with:
- Tool Input node receives:
{"args": {"email": "john@example.com"}, "context": {}} - Query runs with email filter
- Results returned to AI
AI Agent Response#
{
"customer_id": "cust_12345",
"name": "John Smith",
"email": "john@example.com",
"status": "active"
}
Important Behaviors#
Parameter Passing#
- Every invocation delivers exactly one shape to the Tool Input node:
{ "args": { "op": "query", "context": "model-provided value" }, "context": { "workspace": "eng", "source": "parent workflow" } } - With
supply_contextoff, or with no data on theinputsocket,contextis{}— never absent and nevernull - A model-provided argument named
contextstays insideargs; the payload is wrapped, not merged, so it cannot reach the supplied context - An agent session calling this tool supplies its own
session_idas the context, so the target knows which session called it
The contract lives on the callee#
- The tool description is the target's Tool Input
description, and the argument schema itsargs_schema; both are read on every run, and the schema is emitted as the runtime function parameters schema for AI tool calling - Editing the target — a new version, a changed description or schema — reaches this caller on its next run; nothing is cached across runs
- The Tool Input node validates
argsagainst that schema and fails the run when they do not conform - A target whose start node is not a Tool Input node fails this node at execution, naming what is wrong
The Tool Input description is critical#
Without a good description on the target's Tool Input node, the AI won't know:
- When to use the tool
- What parameters to provide
- What the tool returns
Good description: "Use this when you need current weather. Pass 'city' (required) and optional 'units' ('metric' or 'imperial'). Returns temperature, conditions, and forecast."
Bad description: "Gets weather data" // Too vague
Execution Context#
- Subworkflows run in the same workspace as the calling agent
- They have access to the same tables, documents, and connections
- The target workflow should use
set_workflow_output; that value is returned directly to the AI set_workflow_outputis not a terminator or success marker; failures elsewhere still fail the workflow and return a tool error- Required goal/effect nodes keep the default
base_config.failure_mode = "stop": their failure stops the dependent branch, marks the workflow failed, and returns a tool error."stop_workflow"is a rare emergency setting that immediately terminates the entire workflow, including independent branches
Best Practices#
Define clear parameter schemas#
Declare them on the target's Tool Input node:
Good:
{
"type": "object",
"properties": {
"query": { "type": "string", "description": "Search query" },
"limit": { "type": "number", "description": "Max results (1-100)" }
},
"required": ["query"]
}
Bad:
{
"type": "object",
"description": "Some parameters"
}
Write actionable Tool Input descriptions#
Good: "Use this when the user asks about their account balance. Returns current balance and recent transactions. No parameters needed."
Bad: "Account tool" // Doesn't explain when to use it
Keep workflows focused#
Good:
- One workflow for sentiment analysis
- One workflow for customer lookup
- One workflow for data enrichment
Bad:
- One giant workflow that does everything // Hard to describe and use
Handle missing inputs gracefully#
In your target workflow, handle cases where optional parameters are missing:
[Tool Input] → (args) → [Branch: Check if email is provided]
↓ yes
→ [Query by email]
↓ no
→ [Check if ID is provided]
↓ yes
→ [Query by ID]
↓ no
→ [Return error: "Need email or ID"]
Comparison with Related Nodes#
| Node | Use Case | Parameter Definition |
|---|---|---|
| Subworkflow Tool | Execute workflow as AI tool | JSON Schema on the target's Tool Input node |
| Spawn Agent Tool | Delegate to sub-agent | Task description string |
| Tool Provider | Bundle tools for agent | N/A (provides existing tools) |
| AI Agent | Main reasoning agent | N/A (uses tools) |
Troubleshooting#
AI never calls the tool#
- Check that the target's Tool Input
descriptionclearly explains when to use it - Verify the tool is connected to the AI Agent's tools input
- Ensure the tool name is descriptive and matches the AI's vocabulary
Workflow receives wrong data#
- Verify the target's Tool Input
args_schemadescribes what the graph downstream ofargsexpects - Remember that arguments arrive under
argsand supplied context undercontext - Test the workflow with its own trigger and data nodes before using it as a tool
Schema errors#
args_schemamust be a valid object JSON Schema for providers that enforce tool schemas- Invalid JSON Schema can cause provider-side request rejection before generation starts
- "target does not expose a Tool Input contract" means the selected start node is not a Tool Input node
Related Nodes#
- AI Agent - Can use Subworkflow Tool as one of its tools
- AI Conversation - Can also use Subworkflow Tool
- Tool Provider - Often used alongside to provide additional tools
- Tool Input - Required in target workflows: it declares the contract and receives the invocation
- Spawn Agent Tool - Alternative for agent-based delegation
Inputs
inputRequired
Outputs
tool
Configuration
| Field | Type | Required | Description |
|---|---|---|---|
workflow_id | workflow_ref | Yes | Workflow to execute when the tool is called |
start_node | node | Yes | Tool Input node the invocation starts at |
tool_name | string | Yes | Name that the AI will see for this tool |
supply_context | boolean | No | Supplies this nodes input data as context alongside the arguments supplied by agents, allowing passing mechanical workflow data, ids, or sensitive data without exposing it to the agent |
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). |