Chapter 19 — Workflows with Subagents
TL;DR: A single agent is not always the answer. Workflows orchestrate specialized subagents (one for analysis, another for writing) that work in parallel or sequence.
Workflow patterns
Section titled “Workflow patterns”- Sequential — A does its work → B consumes result → C consumes result
- Parallel — A, B, C run simultaneously, then C synthesizes
- Conditional — If A returned X, call D; if Y, call E
async function analyzeAndWriteWorkflow(topic: string) { const research = await researchAgent.run({topic}); const outline = await outlineAgent.run({research}); const [section1, section2] = await Promise.all([ writerAgent.run({outline: outline.part1}), writerAgent.run({outline: outline.part2}) ]); return editorAgent.run({sections: [section1, section2]});}