All posts

Multi-Agent vs Chains - when graph, when chain?

3 min read
Multi-Agent vs Chains - when graph, when chain?

The problem: which pattern to choose?

You're building an AI system and facing an architecture choice. LangChain offers chains - sequential pipelines. LangGraph provides graphs with cycles and multi-agents. Which to choose?

The answer isn't obvious. Research from late 2025 shows that more agents doesn't always mean better results. In tasks with more than 10 tools, multi-agent systems lose 2-6x efficiency compared to single agents.


Chain - sequential processing

How it works

A chain is a DAG (Directed Acyclic Graph) - tasks execute sequentially, no loops. Each step passes results to the next.

Input → Retrieve → Process → Generate → Output

LangChain example

python
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
from langchain_core.output_parsers import StrOutputParser

prompt = ChatPromptTemplate.from_template(
    "Summarize this text: {text}"
)

chain = prompt | ChatOpenAI() | StrOutputParser()

result = chain.invoke({"text": "Long document..."})

When is chain enough?

  • RAG - retrieve → augment → generate
  • Summarization - one document, one result
  • Classification - input → analysis → category
  • Transformations - format A → format B

Graph - non-linear flows

How it works

Graphs allow cycles, branching, and dynamic decisions. An agent can return to a previous step, choose a different path, iterate until success.

Supervisor Pattern
Supervisor Pattern

LangGraph example

python
from langgraph.graph import StateGraph, START, END
from typing import TypedDict

class State(TypedDict):
    messages: list
    next_agent: str

def supervisor(state: State) -> dict:
    # Decides which agent should act
    return {"next_agent": "research"}

def research_agent(state: State) -> dict:
    # Searches for information
    return {"messages": state["messages"] + ["Found data..."]}

def writer_agent(state: State) -> dict:
    # Generates response
    return {"messages": state["messages"] + ["Here's the report..."]}

graph = StateGraph(State)
graph.add_node("supervisor", supervisor)
graph.add_node("research", research_agent)
graph.add_node("writer", writer_agent)

graph.add_edge(START, "supervisor")
graph.add_conditional_edges("supervisor", lambda s: s["next_agent"])
graph.add_edge("research", "supervisor")
graph.add_edge("writer", END)

app = graph.compile()

Comparison: Chain vs Graph

AspectChain (LangChain)Graph (LangGraph)
FlowLinear, sequentialNon-linear, with cycles
StatePassed between stepsCentral, shared
DebuggingSimpleRequires tools (Studio)
ComplexityLowHigh
Use casesRAG, simple pipelinesMulti-agent, iterations

Supervisor Pattern - agent coordination

In a multi-agent system you need a coordinator. Supervisor Pattern is an architecture where a central agent decides which specialized agent should act.

When Supervisor?

  • You have different domains - calendar, email, CRM, database
  • Each domain has complex logic or many tools
  • You need centralized control of the flow

When single agent?

  • You have few simple tools
  • Tasks are homogeneous
  • You want a quick prototype

Research: more agents ≠ better

Research from 2025 (Stanford, Harvard, Google) shows surprising results:

Tool-heavy environments

In environments with >10 tools, multi-agent systems lose 2-6x efficiency. Coordination overhead outweighs specialization benefits.

Financial analysis

For financial tasks, centralized multi-agent (supervisor + sub-agents) gave 80% better results than a single agent. But independent multi-agent was only 57% better.

Conclusion

"Multi-agent effectiveness depends on trade-offs between architecture and task characteristics."


When to choose what?

Stay with Chain when:

  • Workflow is linear and predictable
  • You need a quick MVP
  • You have simple RAG or summarization
  • Team has no experience with graphs

Choose Graph when:

  • You need iterative loops (agent improves its work)
  • You have conditional branching (different paths for different cases)
  • You're building a multi-agent system with specialized roles
  • You need checkpoints and resumption

Avoid multi-agent when:

  • You have many tools (>10) in one agent
  • Tasks are homogeneous
  • You don't have time to test interactions between agents

Practical path

1. Start with a single agent

python
from langchain_openai import ChatOpenAI
from langchain_core.tools import tool

@tool
def search_database(query: str) -> str:
    """Searches the database."""
    return f"Results for: {query}"

llm = ChatOpenAI().bind_tools([search_database])

2. When complexity grows - add LangGraph

python
from langgraph.prebuilt import create_react_agent

agent = create_react_agent(
    model=ChatOpenAI(),
    tools=[search_database],
    checkpointer=memory  # State persistence
)

3. When you need specialization - Supervisor

python
from langgraph.graph import StateGraph

# Supervisor decides, agents execute
graph = StateGraph(State)
graph.add_node("supervisor", supervisor_node)
graph.add_node("researcher", research_agent)
graph.add_node("writer", writer_agent)

Summary

Task complexityRecommendation
Simple (RAG, summary)Chain (LangChain)
Medium (iterations, conditions)Graph (LangGraph)
High (multi-domain)Supervisor + sub-agents
Very high (>10 tools)Single agent (!!)

Don't overcomplicate without need. A single well-configured agent often beats an army of poorly coordinated agents.


Learn more

Need help with AI architecture? Contact me - I'll help choose the right approach for your case.