Multi-Agent Patterns
Sub-Agents (agent_ref)
Section titled “Sub-Agents (agent_ref)”Delegate work to another agent by reference. The parent flow pauses while the sub-agent executes, then resumes with the result.
{ "type": "agent_ref", "data": { "type": "agent_ref", "agentRef": "research-assistant", "refType": "slug", "inputMapping": { "message": "{{input.query}}" }, "outputVariable": "research_result", "inheritContext": true, "timeout": 60000 }}Input Mapping
Section titled “Input Mapping”Map parent variables to sub-agent inputs using {{variable}} interpolation.
Context Inheritance
Section titled “Context Inheritance”When inheritContext is true, the sub-agent receives the parent’s user context (userId, session, etc.).
Agent Pools
Section titled “Agent Pools”Run multiple agents and combine their outputs using a strategy.
Strategies
Section titled “Strategies”| Strategy | Behavior |
|---|---|
best_of | Run all agents, use an evaluator LLM to pick the best response |
aggregate | Concatenate all responses |
vote | Return the most common response |
fastest | Return the first response that completes |
{ "type": "agent_pool", "data": { "type": "agent_pool", "agents": [ { "ref": "writer-agent", "refType": "slug" }, { "ref": "editor-agent", "refType": "slug" } ], "strategy": "best_of", "evaluationPrompt": "Pick the response with the best writing quality.", "evaluatorModelId": "openai/gpt-4o", "maxConcurrency": 3, "agentTimeout": 30000 }}Map-Reduce
Section titled “Map-Reduce”Process an array of items in parallel, then combine results.
- Map: For each item in the input array, run a sub-agent
- Reduce: Combine all results using a strategy
{ "type": "map_reduce", "data": { "type": "map_reduce", "inputVariable": "articles", "mapAgentRef": "summarizer", "mapAgentRefType": "slug", "itemTemplate": "Summarize this article: {{item.title}}\n\n{{item.content}}", "reduceStrategy": "concatenate", "maxConcurrency": 5 }}Reduce Strategies
Section titled “Reduce Strategies”| Strategy | Behavior |
|---|---|
concatenate | Join all results with newlines |
merge | Deep merge JSON results |
custom | Use reduceExpression to combine |