{"slug": "how-to-orchestrate-better-multi-agent-systems-12-patterns-trade-offs-and-when-to", "title": "How to Orchestrate Better Multi-Agent Systems: 12 Patterns, Trade-offs, and When Not to Use Them", "summary": "A developer published a guide to 12 multi-agent orchestration patterns, drawn from the implementation in the open-source langchainrust v0.32.0 project, covering ReAct, PlanExecute, Supervisor, GroupChat, Swarm, FanOutFanIn, ReWOO, Reflexion, Tree of Thoughts, LATS and Self-Discover. For each pattern the guide explains the problem it solves, its token and tool-call costs, and when it should not be used, with a worked comparison-brief example estimating roughly 4k–6k tokens for ReAct versus two model calls for ReWOO. The author's stated principle is to get the simplest single-agent loop working first and add structure only based on measurements, rather than starting with multi-agent designs.", "body_md": "Based on the real implementation in langchainrust v0.32.0\n\n(`crates/lc-agents/src/orchestrator/`, `crates/lc-langgraph/src/presets.rs`).\n\nThis is not a \"how to call the API\" tutorial. For every pattern it answers\n\nthree questions: what problem it solves, what it costs, and when you should\n\n**not** use it.\n\nIntended for backend and LLM application engineers building Agents, RAG, and\n\nmulti-agent systems.\n\nAll diagrams are plain-text line drawings. No Mermaid required; they render\n\ndirectly in Markdown and on CSDN.\n\nRepository: [https://github.com/atliliw/langchainrust](https://github.com/atliliw/langchainrust)\n\nIf you do not want to read the whole article, match your problem first:\n\n| Your problem | Start with | \n|---|---|\n| One objective, one tool set, decide as you go | ReAct (with the FunctionCalling variant) | \n| Multi-step task, plan first and then execute | PlanExecute | \n| Fixed steps with a clear order | SequentialPipeline | \n| Decide at runtime which specialist goes next | Supervisor | \n| Multiple roles need to read each other and debate/review | GroupChat | \n| No center; specialists hand control to each other | Swarm | \n| Same task needs parallel perspectives, voting, or best-of | FanOutFanIn | \n| Plan first, execute later, avoid repeated observations | ReWOO | \n| The answer can be judged, and self-correction helps | Reflexion | \n| One sample is unreliable; compare several lines of thought | Tree of Thoughts | \n| Actions have side effects and you need rollback | LATS | \n| Task types vary and you need a custom reasoning structure | Self-Discover | \n\nThese are the 12 patterns used throughout this article. FunctionCalling is a\n\nnative tool-calling variant of ReAct and is not counted separately.\n\nLangGraph presets are not a 13th pattern; they are a graph-based way to carry\n\nthe patterns above, useful when you need persistence, approvals, or recovery.\n\nA simple decision order:\n\n```\nAre the steps fixed?\n├─ Yes → Sequential / FanOutFanIn\n└─ No → Do you need multiple roles?\n   ├─ No → single-agent loop / PlanExecute / search\n   └─ Yes → Do the roles need to see each other's messages?\n      ├─ Yes → GroupChat\n      └─ No → Supervisor / Swarm\n```\n\nThe one-line principle: **get the simplest single-agent loop working first, then add structure based on measurements. Do not start with multi-agent.**\n\nA single model call has a capability ceiling set by the model. Real tasks are\n\nrarely one question and one answer:\n\nThe root cause is usually not that \"the model is not smart enough.\" It is that\n\n**the model has not been given a suitable organization**. The same model can\n\nbehave very differently when placed in different loops, routers, or search\n\nstructures.\n\nlangchainrust unifies these organizations behind the `Orchestrator` trait\n\n(`crates/lc-agents/src/orchestrator/mod.rs`):\n\n```\n#[async_trait]\npub trait Orchestrator: Send + Sync {\n    type Input;\n    type Output;\n\n    async fn run_with_context(\n        &self,\n        input: Self::Input,\n        ctx: &RunContext,\n    ) -> Result<Self::Output, AgentError>;\n\n    fn last_usage(&self) -> Option<RunUsage> { None }\n}\n```\n\n`RunContext` carries the `trace_id`, a shared workspace, and an optional governor\n\n(timeout/cancellation). Every orchestrator can enter LCEL and can also be wrapped\n\nas a tool for a parent agent.\n\nThe rest of this article classifies patterns by **collaboration structure**, not\n\nby feature name.\n\nAssume the task is: look up three sources (product docs, competitor pricing,\n\nuser reviews) and write a comparison brief with citations.\n\nShared assumptions: 200 tokens per tool observation, 300 tokens per generation,\n\nsystem prompts excluded. These are order-of-magnitude estimates, not benchmarks.\n\n| Pattern | Model calls | Tool calls | Context behavior | Rough tokens | What it feels like | \n|---|---|---|---|---|---|\n| ReAct | 6–8 turns | 3 | every observation is re-injected | 4k–6k | simple, but gets more expensive as it searches | \n| ReWOO | 2 (planner + solver) | 3 | observations are read once by the solver | 2k–3k | cheap if the plan is right | \n| Supervisor | 1 routing call + 2–3 workers | 3 | scratchpad summaries | 3k–5k | dynamic, but routing can wobble | \n| GroupChat | 4 roles × 2 rounds = 8 calls | 3 | full transcript | 12k–15k | thorough discussion, most expensive | \n\nThe same task: ReAct \"searches and thinks as it goes,\" ReWOO \"draws a DAG first\n\nand then executes,\" Supervisor \"finds someone to do it,\" and GroupChat \"holds a\n\nmeeting.\" Picking the wrong structure often does not produce a wrong answer; it\n\nproduces an answer that is an order of magnitude more expensive or slower.\n\nDo not go by feel. First record six metrics on the same batch of tasks:\n\n| Metric | What it tells you | \n|---|---|\n| task success rate | whether the end-to-end task is completed | \n| tool-call accuracy | share of correct tools and correct arguments | \n| retries per task | average number of retries | \n| tokens per success | tokens consumed per successful task | \n| P95 latency | tail latency | \n| human intervention rate | share of tasks that need a human takeover | \n\nThen choose by failure mode:\n\n| Failure mode | Prefer | \n|---|---|\n| Missing lookups, wrong lookups, wrong order | PlanExecute / ReWOO | \n| The answer can be judged, but the first attempt is wrong | Reflexion / ToT | \n| Subtasks are independent | FanOutFanIn | \n| Roles need to challenge and review each other | GroupChat | \n| Input decides the specialist; routing is not fixed | Supervisor | \n| Actions have side effects and need rollback | LATS | \n\nDecision rule: **the success-rate gain from the new structure must exceed the increase in tokens and latency**. Otherwise you are over-orchestrating. Run an\n\nThe most basic class: the model repeatedly \"thinks → calls a tool → observes the\n\nresult → thinks again\" until it produces the final answer.\n\n```\nUser input\n   │\n   ▼\n[LLM thinks] ──needs tool──> [Run tool]\n   ▲                         │\n   └────── observation back ─┘\n   │\n   └── no tool needed ──> [Final answer]\n```\n\n`ReActAgent`: the model emits `Thought / Action / Action Input`, a parser runs\nthe tool, and the `Observation` is appended back to the context. Good for text\nprotocols and models without native tool calling.`FunctionCallingAgent`: not a separate orchestration pattern, but the native\ntool-calling variant of the ReAct loop. Arguments are structured JSON, so no\nfree-text parsing is needed. Good for OpenAI/Anthropic-style function calling.`PlanExecuteAgent`: produces a plan first, executes it step by step, and\nreplans when necessary. Good for tasks with many steps that need an explicit\nplan.\nMinimal call (ReAct):\n\n``` js\nlet agent = ReActAgent::new(llm, prompt_template);\nlet executor = AgentExecutor::new(Arc::new(agent), tools)\n    .with_max_iterations(10);\n\nlet answer = executor.invoke(\"look up ...\".to_string()).await?;\n```\n\n**Cost**: every turn re-injects the history of observations, so tokens grow\n\nlinearly with the number of turns. The more tools you have, the longer the prompt\n\nand the more likely the model is to pick the wrong tool.\n\n**When not to use it**: if the tool-call graph can be determined up front (for\n\nexample, \"look up A, then use A's result to look up B\"), ReAct's turn-by-turn\n\ndecision-making is wasted. Use ReWOO instead.\n\nA router model decides each round \"who gets the next subtask, or are we done?\"\n\nWorkers are leaf agents. Their output is fed back into a scratchpad and handed to\n\nthe router again.\n\n```\n[objective]\n    │\n    ▼\n[Supervisor router]\n    ├──> [Researcher] ──result──┐\n    ├──> [Writer]     ──result──┼──> scratchpad\n    └──> [Critic]     ──result──┘         │\n                                        ▼\n                              next round / FINISH\n```\n\n`crates/lc-agents/src/orchestrator/supervisor.rs`\n`max_rounds` is bounded; router output supports JSON plus a\n`<<<NEXT>>>` fallback; workers cannot recursively delegate (one-level\nrecursion guard).\nMinimal call:\n\n``` js\nlet researcher = Arc::new(TaskAdapter::from_executor(research_executor));\nlet writer = Arc::new(TaskAdapter::from_executor(writer_executor));\nlet supervisor = Supervisor::new(\n    router_llm,\n    vec![(\"Researcher\".into(), researcher), (\"Writer\".into(), writer)],\n    8,\n);\n\nlet answer = supervisor\n    .run_with_context(AgentTask::new(\"...\"), &RunContext::new_random())\n    .await?;\n```\n\nEvery participant can see **the full history of messages**, and one participant\n\nspeaks per round. There are three speaker selectors: round-robin, keyword, and\n\nLLM. There are three termination modes: max rounds, a moderator `FINISH`, and a\n\nconsensus threshold (whichever fires first).\n\n```\n[objective]\n    │\n    ▼\n┌──────────────────────────────┐\n│ Shared transcript            │\n│ [Planner][Researcher][Critic]│\n└──────────────┬───────────────┘\n               │ read full history each round\n               ▼\n      [Speaker Selector]\n      round-robin / keyword / LLM\n               │\n               ▼\n        [Current speaker]\n               │\n               ▼\n       append speech to transcript\n               │\n               ▼\n        termination met?\n          │         │\n         no         yes\n          │         │\n          └─next round └─> [answer]\n```\n\n`crates/lc-agents/src/orchestrator/group_chat.rs`\nA minimal example:\n\n```\nuse std::sync::Arc;\nuse langchainrust::{\n    AgentTask, GroupChat, GroupChatConfig, GroupParticipant, Orchestrator,\n    RunContext, SpeakerSelector, Termination,\n};\n\n// planner / researcher / critic / writer are all\n// Arc<dyn Orchestrator<Input = AgentTask, Output = String>>\nlet chat = GroupChat::new(\n    vec![\n        GroupParticipant::new(\"Planner\", planner).with_role(\"break down the task\"),\n        GroupParticipant::new(\"Researcher\", researcher).with_role(\"add facts\"),\n        GroupParticipant::new(\"Critic\", critic).with_role(\"find problems\"),\n        GroupParticipant::new(\"Writer\", writer).with_role(\"write the final answer\"),\n    ],\n    GroupChatConfig::new(6, SpeakerSelector::RoundRobin, Termination::MaxRounds),\n)?;\n\nlet answer = chat\n    .run_with_context(\n        AgentTask::new(\"Write a technical brief on reranking\"),\n        &RunContext::new_random(),\n    )\n    .await?;\n```\n\nIf you already have an `AgentExecutor`, wrap it with `TaskAdapter` first and it\n\ncan be used as a participant.\n\nThere is no central router. The current agent either answers directly or hands\n\ncontrol to an **allowed** peer, carrying its context variables with it.\n\n```\n[entry A] ──handoff(B)──> [B] ──handoff(C)──> [C]\n    │                      │                   │\n    └─ answer directly     └─ answer directly  └─ answer directly\n\nConstraints: the target must be in the allowlist; max_handoffs prevents ping-pong.\n```\n\n`crates/lc-agents/src/orchestrator/swarm.rs`\n`{\"handoff\":\"B\",\"reason\":\"...\",\"context\":{...}}`; weaker models can\nuse `<<<HANDOFF>>>B<<<END_HANDOFF>>>`.` max_handoffs` prevents ping-pong.\nSend the same input to multiple agents in parallel, then aggregate the results.\n\n```\n             ┌──> [Worker A] ──┐\n             │                 │\n[objective] ─┼──> [Worker B] ──┼──> [Aggregator] ──> answer\n             │                 │\n             └──> [Worker C] ──┘\n```\n\n`crates/lc-agents/src/orchestrator/fan_out_fan_in.rs`\nChain stages in a fixed order; each stage's output becomes the next stage's input.\n\n```\n[input] ──> [Stage 1] ──> [Stage 2] ──> [Stage 3] ──> [output]\n```\n\n`crates/lc-agents/src/orchestrator/sequential.rs`\n| Structure | Where decisions happen | Good for | Not good for | \n|---|---|---|---|\n| Supervisor | central router | dynamic specialist selection | specialists must see each other's full messages | \n| GroupChat | speaker selector | debate/review/role play | low latency, high QPS | \n| Swarm | each agent locally | decentralized collaboration | globally optimal scheduling | \n| FanOutFanIn | fixed | multiple perspectives/voting | multi-round discussion | \n| Sequential | fixed | stable pipelines | runtime decisions | \n\n**Where the boundary blurs**: if the Supervisor scratchpad turns into \"several\n\nspecialists interrupting each other,\" or a worker needs another worker's full\n\nargument to continue, you probably want GroupChat. Conversely, if only one person\n\nkeeps working in a GroupChat while everyone else watches, fall back to Supervisor;\n\nit is cheaper.\n\nA three-role loop: the actor produces an answer → the evaluator judges it → on\n\nfailure, the reflector compresses the feedback into a reusable lesson → the next\n\nround's actor retries with all lessons.\n\n```\n[actor] ──> answer ──> [evaluator] ──pass──> [final]\n   ▲                        │\n   │                       fail\n   │                        ▼\n   └──── [reflector] <── feedback\n         distills a lesson into the next round\n```\n\n`crates/lc-agents/src/orchestrator/reflexion.rs`\n`max_attempts` is at least 1; when the budget is exhausted, it returns the last\nanswer with `success=false`.\n**Why not just retry?** Retrying is repeated sampling; the failure reason is not\n\nretained. Reflexion compresses the failure into a \"do not do this next time\"\n\nlesson and feeds it into the next round.\n\n**In practice**: tasks that converge within 2–3 attempts (code repair, format\n\nvalidation, fact checking) benefit most. After the 4th attempt you are often just\n\nburning tokens.\n\n**Cost**: `attempts × (actor + evaluator + reflector)`, usually 3–5× a normal\n\nanswer.\n\nEach expansion has the generator produce `breadth` candidate thoughts, the\n\nevaluator scores each one, and each level keeps only the top `beam_width` states\n\nto expand further, with `max_nodes` as a hard cap.\n\n```\n                   [root]\n                  /  |  \\\n              [c1] [c2] [c3]   ← generator: breadth\n                 \\   |   /\n                [evaluator scores]\n                       │\n              keep top beam_width\n                       │\n                  expand next level\n```\n\n`crates/lc-agents/src/orchestrator/tree_of_thoughts.rs`\n`breadth × expanded nodes`, clearly\nhigher than a single chain.\n**Why not just sample more?** Sampling is \"parallel luck.\" ToT narrows level by\n\nlevel using scores, spending budget on more promising branches.\n\n**In practice**: `breadth=2–3`, `beam_width=2`, `max_nodes=10–20` are common\n\nstarting points. Go higher and evaluator cost runs away first.\n\n**Boundary**: if the evaluator is more expensive than the generator, or the task\n\nhas no comparable intermediate states, ToT is not worth it. Fall back to a single\n\nchain plus multiple samples.\n\nToT searches \"thoughts\"; LATS searches \"actions\" with environment feedback. Four\n\nstages: UCT selection → expand candidate actions → greedy rollout → value\n\nbackpropagation.\n\n```\n[UCT select] ──> [expand actions] ──> [rollout] ──> [backpropagate]\n     ▲                                                   │\n     └───────────────────────────────────────────────────┘\n```\n\n`crates/lc-agents/src/orchestrator/lats.rs`\n`LatsEnvironment::step(path, action)` must be derived from the **The key difference from ToT**: ToT evaluates \"is this thought good?\" LATS\n\nevaluates \"what does the environment look like after this action?\" The former\n\nneeds no environment; the latter requires a replayable/snapshot-able environment.\n\n**In practice**: tasks with tests, simulators, or sandboxes fit best. Do not point\n\nLATS directly at irreversible real-world actions (placing orders, sending\n\nmessages, transferring money).\n\n**Cost**: every expansion needs a rollout, usually tens of times a single chain.\n\nIt is only worth it when \"a wrong move is expensive and rollback is possible.\"\n\nReAct injects one observation per turn. ReWOO separates \"planning\" from\n\n\"execution\": the planner emits the entire tool-call graph at once (`#E1`\n\nreferences earlier results), the executor runs it in dependency waves, and the\n\nsolver sees all observations once and answers.\n\n```\n[planner]\n    │ emits the whole tool DAG\n    ▼\n #E1 ──> #E2\n   │       │\n   └──> #E3\n          │\n[executor] runs by dependency wave\n          │\n          ▼\n[solver] <── all observations\n```\n\n`crates/lc-agents/src/orchestrator/rewoo.rs`\n`max_retries`; errors carry step/tool/attempts.\n\n``` js\nlet rewoo = ReWooAgent::new(\n    planner,\n    solver,\n    tool_executor, // Arc<dyn ReWooToolExecutor>\n    ReWooConfig::default().with_tools([\"search\", \"summarize\"]),\n);\nlet result = rewoo.run_detailed(\"...\", &RunContext::new_random()).await?;\n```\n\nThe composer combines a set of atomic reasoning modules (decompose, critique,\n\nverify, analogize, ...) into a task-specific reasoning structure, and the solver\n\nexecutes it step by step.\n\n```\n[atomic reasoning modules]\n decompose / critique / verify / analogize ...\n        │\n        ▼\n   [composer] ──> [reasoning structure] ──> [solver] ──> answer\n```\n\n`crates/lc-agents/src/orchestrator/self_discover.rs`\n**Why not fixed CoT?** Fixed CoT assumes the task type is consistent.\n\nSelf-Discover selects reasoning modules first and then assembles a structure,\n\nwhich suits mixed analysis tasks.\n\n**In practice**: one extra composer call, but it avoids \"using the wrong recipe.\"\n\nA structure parse failure is a direct error; it does not silently fall back to\n\nCoT.\n\n**Boundary**: simple Q&A and low-latency tasks do not need it. It fits\n\n\"analysis/planning\" tasks, not \"look up one number\" tasks.\n\nThe patterns above are orchestrators in `lc-agents`. In `lc-langgraph` you can\n\nalso build them directly as graphs:\n\n`create_react_agent` / `create_supervisor` / `create_swarm`\n(`crates/lc-langgraph/src/presets.rs`) are assembled with a normal `StateGraph`,\nso checkpointing, streaming, and interrupts come naturally.`GraphTool` (`crates/lc-agents/src/graph_tool.rs`) wraps a compiled graph as a\n`BaseTool`, so a parent agent can call the whole graph like an ordinary\nfunction.`Send` primitive supports runtime-determined map-reduce branching; `Command`\nsupports resume and fork (time travel).\n**When to use a graph instead of an orchestrator**:\n\n| Pattern | Where decisions happen | Context cost | Determinism | Best for | Typical failure mode | \n|---|---|---|---|---|---|\n| ReAct | model, every turn | high (observations re-injected) | low | exploratory tool tasks | wrong tool / loop | \n| PlanExecute | plan first, then execute | medium | medium | multi-step tasks | stale plan | \n| Supervisor | central router | medium | medium | dynamic specialist selection | routing wobble | \n| GroupChat | speaker selector + shared record | high (full transcript) | low | debate / review | off-topic, cost explosion | \n| Swarm | each agent locally | low (context only) | low | decentralized collaboration | ping-pong, detours | \n| FanOutFanIn | fixed | medium | high | multiple perspectives / voting | aggregation conflicts | \n| Sequential | fixed | low | high | stable pipelines | inflexible | \n| Reflexion | actor/evaluator/reflector | medium | medium | judgeable correction | unreliable evaluator | \n| ToT | search + value model | high (many branches) | medium | planning / reasoning | branch explosion | \n| LATS | MCTS + environment | high | medium | action tasks with rollback | non-replayable environment | \n| ReWOO | one-shot plan | low | high | tool DAGs | unexecutable plan | \n| Self-Discover | composer designs first | medium | medium | varying task types | structure parse failure | \n\nFunctionCalling is folded into the ReAct row: it reuses the same\n\n\"observation back into context\" loop, with native JSON tool arguments.\n\nLangGraph presets are not in the table: they are a graph-based delivery\n\nmechanism, not a 13th orchestration pattern.\n\n`max_nodes`, and\n`depth` are hard limits. An orchestrator must never \"keep running because the\nmodel did not say stop.\"`<<<HANDOFF>>>`, `<<<THOUGHT>>>`, `<<<ACTION>>>`), and then\nerrors out—there is no silent fallback to round-robin.`speaker` / `round` / `step`,\ninstead of a generic \"agent failed.\"`ExecutorOrchestrator` (the adapter that wraps an\n`AgentExecutor` as an `Orchestrator`) gets exact token counts from\n`AgentMetrics` (per-run executor metrics); `TaskAdapter` prefers real usage\nand only falls back to `chars/4` estimation when unavailable.\nIf a single agent can complete the task, multi-agent often just splits the\n\nfailure into more pieces. Get the single agent's prompt, tools, and error\n\nhandling stable first, then consider collaboration.\n\nEvery additional agent adds tokens, latency, failure surface, and debugging cost.\n\nThe value of multi-agent comes from role separation and mutual checking, not\n\nfrom the number of agents.\n\nGroupChat without `max_rounds`, Swarm without `max_handoffs`, or Reflexion\n\nwithout `max_attempts` all turn into \"keep running because the model did not say\n\nstop.\"\n\nReflexion / ToT / LATS all depend on an evaluator. When the evaluator itself is\n\nunreliable, more search just makes the model wrong more consistently.\n\nGroupChat is multi-round and serial, with high token and latency costs. For a\n\nlow-latency, high-QPS main path, a single agent or Supervisor fits better.\n\nGroupChat is better for offline review, complex decisions, and multi-role\n\ncreative work.\n\nOrchestration is not \"the more, the better.\" Every extra layer adds tokens,\n\nlatency, and failure surface. The valuable approach is:\n\nWith the same model, the right organization improves quality while reducing\n\ncost; the wrong one only packages the failure in more complexity.", "url": "https://wpnews.pro/news/how-to-orchestrate-better-multi-agent-systems-12-patterns-trade-offs-and-when-to", "canonical_source": "https://dev.to/laolei/how-to-orchestrate-better-multi-agent-systems-12-patterns-trade-offs-and-when-not-to-use-them-3pf", "published_at": "2026-12-01 03:41:17+00:00", "updated_at": "2026-12-01 03:44:02.621805+00:00", "lang": "en", "topics": ["ai-agents", "large-language-models", "ai-tools", "developer-tools"], "entities": ["langchainrust", "ReAct", "PlanExecute", "Supervisor", "GroupChat", "Swarm", "FanOutFanIn", "ReWOO"], "also_reported_by": [], "takeaway": "Start with the simplest single-agent loop and add multi-agent structure only when measurements justify it; for a three-source comparison brief, ReAct costs roughly 4k–6k tokens across 6–8 turns while ReWOO needs two model calls by planning before executing.", "recommendation": {"advice": "Match the orchestration pattern to the task shape—fixed steps to Sequential, runtime routing to Supervisor, cross-role debate to GroupChat—and measure token and tool-call costs before adopting multi-agent designs.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/how-to-orchestrate-better-multi-agent-systems-12-patterns-trade-offs-and-when-to", "markdown": "https://wpnews.pro/news/how-to-orchestrate-better-multi-agent-systems-12-patterns-trade-offs-and-when-to.md", "text": "https://wpnews.pro/news/how-to-orchestrate-better-multi-agent-systems-12-patterns-trade-offs-and-when-to.txt", "jsonld": "https://wpnews.pro/news/how-to-orchestrate-better-multi-agent-systems-12-patterns-trade-offs-and-when-to.jsonld"}}