Zum Inhalt springen

Multi-Agent Frameworks

Wissen

Before we talk about frameworks, the most important question first:

!Rule of Thumb: Under 4 Agents, No Framework Needed

If your system consists of 2-3 agents communicating through simple function calls, you don't need a framework. An orchestrator script with API calls is enough. Frameworks bring overhead that only pays off above a certain complexity threshold.

When does a framework pay off?

  • 4+ agents with complex communication patterns
  • When you need dynamic workflows (agents created/removed at runtime)
  • When you need state management across multiple agent steps
  • When you don't want to implement parallelization and error handling yourself
LanguagePython (+ JS Beta)
Agent TypesGraph-based, freely definable
OrchestrationStateGraph with Nodes & Edges
State ManagementTyped State, Checkpointing, Time-Travel
Learning CurveSteep — requires graph concepts
CommunityLarge (LangChain ecosystem)
PricingOpen Source (LangSmith paid)
LanguageTypeScript
Agent TypesEvent-driven, tool-based
OrchestrationWorkflow Engine, Event Streams
State ManagementBuilt-in Persistence, Workflow State
Learning CurveModerate — TypeScript skills sufficient
CommunityGrowing, still small
PricingOpen Source
LanguagePython
Agent TypesRole-based (Agent, Task, Crew)
OrchestrationSequential / Hierarchical Crews
State ManagementSimple — task output as input
Learning CurveFlat — quick to get started
CommunityMedium, actively growing
PricingOpen Source (Enterprise Plan available)

LangGraph (Python/TypeScript, Graph-Based)

LangGraph models multi-agent workflows as directed graphs. Each node is an agent or function, each edge defines the data flow. This gives you maximum control over the workflow -- at the cost of more boilerplate.

from langgraph.graph import StateGraph, END

# State defines what's shared between agents
class AgentState(TypedDict):
    messages: list[str]
    current_task: str
    results: dict

# Build the graph
workflow = StateGraph(AgentState)

# Add agents as nodes
workflow.add_node("researcher", research_agent)
workflow.add_node("analyzer", analysis_agent)
workflow.add_node("writer", writer_agent)

# Edges define the workflow
workflow.add_edge("researcher", "analyzer")
workflow.add_conditional_edges(
    "analyzer",
    should_continue,  # Function decides the next step
    {"write": "writer", "research_more": "researcher"}
)
workflow.add_edge("writer", END)

Strengths: Full control, state management, checkpointing, debugging (Graph-Viz), broad ecosystem. Weaknesses: Verbose, steep learning curve.

Mastra (TypeScript, Declarative / Graph-Based)

Mastra uses a declarative, graph-based model and is built for TypeScript/Node.js teams. Workflows are defined as steps with conditions, and the graph emerges from the declared step sequence.

import { Agent, Workflow } from '@mastra/core';

const researchAgent = new Agent({
  name: 'researcher',
  model: 'claude-sonnet-5',
  instructions: 'You research information on a given topic.',
  tools: [webSearch, documentReader],
});

const analysisWorkflow = new Workflow({
  name: 'analysis-pipeline',
  steps: [
    { agent: researchAgent, input: (ctx) => ctx.query },
    { agent: analyzerAgent, input: (prev) => prev.result },
    {
      condition: (prev) => prev.confidence < 0.8,
      then: { agent: researchAgent, input: (prev) => prev.gaps },
      else: { agent: writerAgent, input: (prev) => prev.analysis },
    },
  ],
});

Strengths: TypeScript-native, declarative, less boilerplate, web integration. Weaknesses: Younger ecosystem, less control, checkpoint support not as mature.

CrewAI (Python, Role-Based)

CrewAI thinks in roles and teams, not graphs or events. You define agents with roles ("Senior Developer", "QA Engineer"), give them tasks, and let them collaborate as a team.

from crewai import Agent, Task, Crew

researcher = Agent(
    role="Senior Research Analyst",
    goal="Find the most relevant information on the topic",
    backstory="You have 15 years of experience in market research.",
    tools=[web_search, document_reader],
    llm="claude-sonnet-5"
)

writer = Agent(
    role="Technical Writer",
    goal="Create a clear, structured report",
    backstory="You've been writing technical documentation for years.",
    llm="claude-haiku-4-5"
)

research_task = Task(
    description="Analyze the current state of {topic}",
    agent=researcher,
    expected_output="Structured summary with sources"
)

write_task = Task(
    description="Write a report based on the research",
    agent=writer,
    expected_output="Finished report in Markdown format",
    context=[research_task]  # Dependency
)

crew = Crew(
    agents=[researcher, writer],
    tasks=[research_task, write_task],
    verbose=True
)

Strengths: Intuitive, minimal code, delegation, quick start. Weaknesses: Less control, harder debugging, scaling limitations.

Verstehen

Framework Comparison: When to Use Which?

CriterionLangGraphMastraCrewAI
LanguagePython, TypeScriptTypeScriptPython
ParadigmGraph-basedDeclarative / Graph-basedRole-based
ControlMaximumMediumMinimum
Learning curveSteepMediumFlat
BoilerplateHighLowVery low
DebuggingExcellent (Graph-Viz)GoodMedium
Best forComplex, plannable workflowsTypeScript teams, web appsPrototypes, simple teams
Production-readyYesIncreasinglyFor simple use cases

*Decision Guide

LangGraph when you need full control (Python or TypeScript). Mastra when you want a TypeScript-native declarative framework. CrewAI when you want a quick prototype. And none of them when you have fewer than 4 agents.

Anwenden

Your team needs declarative workflows with webhook integration in an existing Next.js app. The workflow has 6 agents with conditional branching. Which framework do you choose?

You want to build a weekend prototype: 3 agents should collaboratively research, write, and review a blog post. You're working alone. What's the most pragmatic approach?

Reflect

Frameworks are tools, not solutions. The most important decision is not which framework to use, but whether you need one at all. With the rule of thumb "under 4 agents, no framework needed" and an understanding of each framework's strengths, you can make informed architectural decisions.