An orchestrator coordinates and manages the execution of multiple agents, tools,
and LLMs to complete complex tasks. It's the director that decides what runs, when, in what
order, and how to handle errors.
Functions:
1. Sequential: A → B → C. Use it when each step depends on the previous one.
2. Parallel (fan-out/fan-in): a task is split, run in parallel, and combined.
Ideal for analyzing the same document with 3 agents at once.
3. Conditional: depending on the result, the flow takes different paths.
Example: premium customer → VIP flow; new customer → onboarding flow.
4. Iterative: an agent refines its output until a criterion is met.
Example: generate code → run tests → regenerate if it fails → until it passes.
5. Hierarchical: a supervisor delegates to specialists and aggregates results.
The most powerful pattern for complex systems.
LangGraph is the standard in the Python/LangChain ecosystem. It models the workflow as a graph where nodes are operations and edges are transitions. With checkpointing in Redis or PostgreSQL, workflows survive restarts and support pauses for human validation.
# Multi-agent orchestrator: parallel analysis with LangGraph
from langgraph.graph import StateGraph, END
from typing import TypedDict, Annotated, List
import operator
class State(TypedDict):
task: str
analysis: Annotated[List[str], operator.add]
report: str
def finance_agent(state: State) -> State:
result = llm.invoke(f"Analyze the financial aspects of: {state['task']}")
return {"analysis": [f"Finance: {result.content}"]}
def legal_agent(state: State) -> State:
result = llm.invoke(f"Analyze the legal aspects of: {state['task']}")
return {"analysis": [f"Legal: {result.content}"]}
def risk_agent(state: State) -> State:
result = llm.invoke(f"Assess the risks of: {state['task']}")
return {"analysis": [f"Risk: {result.content}"]}
def synthesis(state: State) -> State:
combined = "\n\n".join(state["analysis"])
report = llm.invoke(f"Generate an executive report:\n{combined}")
return {"report": report.content}
graph = StateGraph(State)
for name, fn in [("finance", finance_agent), ("legal", legal_agent),
("risk", risk_agent), ("synthesis", synthesis)]:
graph.add_node(name, fn)
graph.set_entry_point("finance")
# All 3 agents run, then synthesis aggregates
graph.add_edge("finance", "synthesis")
graph.add_edge("legal", "synthesis")
graph.add_edge("risk", "synthesis")
graph.add_edge("synthesis", END)Carlos Montiel is an enterprise AI solutions architect with experience in LLMs, Agents, RAG, and orchestration across Guatemala and Latin America.
Contact Carlos Montiel