Multi-agent systems use multiple AI models working together — each handling different parts of a complex task. Day 1 explains the core patterns and when they are worth the complexity.
A single AI model call works for simple tasks. But complex tasks benefit from multiple specialized agents for three reasons:
| Pattern | When to Use | Example |
|---|---|---|
| Orchestrator | Sequential, dependent tasks | Plan → Research → Write → Edit |
| Debate | When you need verification | Draft → Critique → Improve |
| Pipeline | Parallel processing | Analyze 5 documents simultaneously |
import Anthropic from '@anthropic-ai/sdk';
import * as dotenv from 'dotenv';
dotenv.config();
const client = new Anthropic();
// Agent factory: creates a specialized agent with a role
function createAgent(systemPrompt) {
return async function(userMessage, history = []) {
const messages = [...history, { role: 'user', content: userMessage }];
const response = await client.messages.create({
model: 'claude-opus-4-5',
max_tokens: 2048,
system: systemPrompt,
messages
});
return response.content[0].text;
};
}
// Create specialized agents
const researcher = createAgent(
'You are a thorough researcher. Given a topic, produce a structured research summary with key facts, data points, and open questions.'
);
const writer = createAgent(
'You are a skilled writer. Given research notes, write clear, engaging prose. No jargon. Concrete examples.'
);
const editor = createAgent(
'You are a sharp editor. Review text for clarity, accuracy, and conciseness. Flag weak arguments and vague language. Return the improved version.'
);
// Simple sequential pipeline
async function researchAndWrite(topic) {
console.log('Step 1: Researching...');
const research = await researcher(`Research this topic: ${topic}`);
console.log('Step 2: Writing...');
const draft = await writer(`Write an article based on this research:
${research}`);
console.log('Step 3: Editing...');
const final = await editor(`Edit and improve this article:
${draft}`);
return { research, draft, final };
}
const result = await researchAndWrite('The impact of AI on knowledge work');
console.log('FINAL:
', result.final);