Pipeline
The Pipeline pattern organizes tasks into sequential stages, where the output (artifact) of a preceding stage serves as the input instruction/context for the next stage.
5-Stage Workflow
Input ──► [ Stage A ] ──► (Artifacts) ──► [ Stage B ] ──► (Artifacts) ──► Output
Worker A Worker B
- Definition: Outline the stages, assign specific assistant configurations, and define the handover criteria.
- Setup: Provide a shared directory path via
workspaceOverrideso all stages modify the same project directory. - Execution:
- Before each stage, inspect
agent__listAgents(type="sessions")for an Idle child with the same assistant ID and a compatible workspace. Reuse it withagent__messageToSession; setreset=truewhen the stage is a fresh assignment and the prior conversation/runtime state must be discarded. - Start a new stage with
agent__startSession(..., waitForResult=true)when no suitable child exists, the stage needs a different role or workspace, or the pipeline requires another parallel capacity slot. - Collect the output path and stage summary upon completion.
- Before each stage, inspect
- Handover: Bind the output paths and preceding summaries into the task prompt of the next stage session.
- Final Format: Aggregate the final stage's output and present it to the user.
🛠️ MCP Tools Guide
- Session Reuse: Reusing a reset session preserves workspace files but closes its browser session. Treat each stage as runtime-isolated even when the session identity is reused, and do not reuse a child whose workspace contract does not match the stage.
- Sequential Assignments: Use
agent__messageToSessionwithwaitForResponse=truefor a reused child,agent__startSessionwithwaitForResult=truefor a new child, oragent__checkSession(sessionId, wait=true)to synchronize. - Context Filtering: Avoid passing the entire conversation logs of previous stages to prevent context bloat. Only pass the summarized markdown text and file paths.
See pipeline-specs.md for details.
References
- Pipeline specs
- Handover templates
- Failure recovery