- Context chaining (
>) — next agent receives a task-focused summary of previous step(s) - Pipe chaining (
|) — next agent receives structured outputs as command arguments - Sub-agents — agents call other agents as tools during execution
review and review_ranked as example agents to illustrate the chaining patterns.
Context chaining (>)
Context chaining runs agents sequentially. Before each agent starts, Qodo preloads a task-focused summary of previous sessions, providing the proper context without explicit wiring.
Use when:
- The downstream agent should start with prior conclusions
- The agent can infer its task from context rather than requiring strict inputs
If your downstream agent requires specific structured inputs (e.g.,
review_ranked expects summary and findings), prefer pipe chaining or make those arguments optional.Pipe chaining (|)
Pipe chaining automatically maps the previous agent’s structured output into --set arguments for the next agent. This creates a clear data contract between steps.
Use when:
- You have explicit field dependencies between agents
- The consuming agent requires specific, structured inputs
- You want deterministic, machine-to-machine handoffs
output_schema fields are mapped to the consuming agent’s arguments. For example:
- Producing agent: Must define
output_schemawith the fields to pass - Consuming agent: Must define
argumentswith matching names and types
Sub-agents
Sub-agents allow an agent to invoke other agents as tools during its run. Sub-agents execute in child processes but surface all activity in the parent’s UI and approval flow. Use when:- The parent agent should dynamically decide which specialized agents to invoke
- Steps are optional or conditional
- You need a supervisor/specialist delegation pattern
subagents__<agent_name>. The parent agent’s instructions determine when and how to invoke them.
Example orchestrator instructions:
- Sub-agents inherit auto-approvals from the parent
- Non-auto-approved tool calls prompt in the parent’s UI
- The currently running agent is not exposed as a sub-agent (prevents recursion)
Pattern selection
Context chaining (>):
- The next agent needs awareness of prior work
- Flexible, context-driven handoffs
- The agent can infer the task from the summary
|):
- Strict field dependencies
- Structured, deterministic data flow
- Clear contracts between agents
- Ideal for workflows like
review → review_rankedwhere outputs map to inputs
- Dynamic workflow decisions
- Conditional or optional steps
- Hierarchical delegation patterns
> or |, and use sub-agents within phases for dynamic delegation.
Example workflow: review pipeline
The following examples demonstrate chaining patterns usingreview and review_ranked agents, where:
reviewproduces structured output withsummaryandfindingsfieldsreview_rankedconsumes those fields to prioritize findings
Single agent execution
Pipe chain (recommended for this pattern)
review’s structured output (summary and findings) to review_ranked’s arguments.
Context chain configuration
To use context chaining between these agents, modifyreview_ranked’s argument requirements:
Make arguments optional to accept context instead of strict inputs
Note: This modification is primarily for demonstrating context chaining. For production pipelines where strict input validation is critical, keep required arguments and use pipe chaining.
Sub-agent orchestration
Create an orchestrator agent that dynamically invokes both agents based on runtime conditions. The orchestrator’s instructions might specify:- When to call
subagents__review - Conditions for calling
subagents__review_ranked - How to synthesize results
Troubleshooting
Shell interpretation issues
Always quote the entire chain string:Pipe chain missing fields
If| reports missing fields:
- Verify that the producing agent outputs those fields in its
output_schema - Confirm that the consuming agent declares them as
arguments - Ensure field names match exactly (case-sensitive)
Passing additional arguments
Use--set to provide arguments to specific steps:
Command reference
Design principles
- Use
>for flexible handoffs where agents work from a summarized context - Use
|for strict contracts where exact field mapping is required - Use sub-agents for dynamic logic where runtime conditions determine workflow
- Validate field mappings by ensuring output schemas match argument definitions
- Quote all chains to avoid shell interpretation issues