📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials Generative AI Engineering Multi-Agent Systems

Multi-Agent Systems

5 min read
Orchestrate planner, researcher, writer, and critic agents in pipelines for complex multi-step tasks.

Multi-Agent Systems

Multiple specialised LLM agents collaborate on tasks requiring different expertise or parallel work.

# Agent roles
AGENTS = {
    'planner': {
        'system': 'You are a project planner. Break complex tasks into subtasks.'
    },
    'researcher': {
        'system': 'You research topics and summarise key findings concisely.'
    },
    'writer': {
        'system': 'You write clear, well-structured technical content.'
    },
    'critic': {
        'system': 'You review content for accuracy, clarity, and completeness.'
    },
}

def call_agent(role: str, task: str) -> str:
    return client.messages.create(
        model='claude-sonnet-4-5', max_tokens=1000,
        system=AGENTS[role]['system'],
        messages=[{'role':'user','content':task}]
    ).content[0].text

# Pipeline: plan -> research -> write -> critique -> revise
def run_pipeline(topic: str) -> str:
    plan     = call_agent('planner',    topic)
    research = call_agent('researcher', plan)
    draft    = call_agent('writer',     research)
    feedback = call_agent('critic',     draft)
    final    = call_agent('writer',     draft + '
Revise based on: ' + feedback)
    return final

# Frameworks: LangGraph, AutoGen, CrewAI