Day 1 of 5
⏱ ~60 minutes
Multi-Agent Systems — Day 1

What Are Multi-Agent Systems and When to Use Them

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.

Why Multiple Agents?

A single AI model call works for simple tasks. But complex tasks benefit from multiple specialized agents for three reasons:

The Three Core Patterns

PatternWhen to UseExample
OrchestratorSequential, dependent tasksPlan → Research → Write → Edit
DebateWhen you need verificationDraft → Critique → Improve
PipelineParallel processingAnalyze 5 documents simultaneously

Your First Multi-Agent System

basic-agents.js
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);
Day 1 Exercise
Run the Research-Write Pipeline
  1. Set up the project with the Anthropic SDK.
  2. Copy basic-agents.js and run it with a topic you care about.
  3. Read all three outputs: research, draft, final. How much did each step improve?
  4. Try a different topic. Notice where the pipeline excels and where it falls short.

Day 1 Summary

  • Multi-agent systems use specialized agents for complex tasks that benefit from sequential refinement.
  • Three patterns: orchestrator (sequential), debate (verification), pipeline (parallel).
  • The createAgent() factory pattern makes it easy to create agents with different system prompts.
  • Start with sequential pipelines before adding parallelism or debate loops.
Finished this lesson?