Step 1 of 4Wissen
Before we talk about frameworks, the most important question first:
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
| Category | |||
|---|---|---|---|
| Language | Python (+ JS Beta) | TypeScript | Python |
| Agent Types | Graph-based, freely definable | Event-driven, tool-based | Role-based (Agent, Task, Crew) |
| Orchestration | StateGraph with Nodes & Edges | Workflow Engine, Event Streams | Sequential / Hierarchical Crews |
| State Management | Typed State, Checkpointing, Time-Travel | Built-in Persistence, Workflow State | Simple — task output as input |
| Learning Curve | Steep — requires graph concepts | Moderate — TypeScript skills sufficient | Flat — quick to get started |
| Community | Large (LangChain ecosystem) | Growing, still small | Medium, actively growing |
| Pricing | Open Source (LangSmith paid) | Open Source | Open 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-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-5"
)
writer = Agent(
role="Technical Writer",
goal="Create a clear, structured report",
backstory="You've been writing technical documentation for years.",
llm="claude-haiku-5-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.
Step 2 of 4Verstehen
Framework Comparison: When to Use Which?
| Criterion | LangGraph | Mastra | CrewAI |
|---|---|---|---|
| Language | Python, TypeScript | TypeScript | Python |
| Paradigm | Graph-based | Declarative / Graph-based | Role-based |
| Control | Maximum | Medium | Minimum |
| Learning curve | Steep | Medium | Flat |
| Boilerplate | High | Low | Very low |
| Debugging | Excellent (Graph-Viz) | Good | Medium |
| Best for | Complex, plannable workflows | TypeScript teams, web apps | Prototypes, simple teams |
| Production-ready | Yes | Increasingly | For simple use cases |
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.
Step 3 of 4Anwenden
Step 4 of 4Reflect
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.