Don't Build Multi-Agents: Cognition's Walden Yan Makes the Case for Single-Threaded Context Engineering
Original author: Walden Yan (Cognition team) (English source: https://cognition.ai/blog/dont-build-multi-agents), Chinese translation and engineering concept supplements: 欧呦 (Oil 欧呦).
This article is compiled from the architecture article Don't Build Multi-Agents published in June 2025 by Walden Yan, co-founder and co-president of Cognition (the team behind Devin). In response to the trend in the open-source community and enterprise engineering of blindly adopting "orchestrator splitting + multiple concurrent sub-agents," Walden Yan draws on practical lessons from Devin's large-scale, long-horizon coding tasks to analyze why multi-agent architectures frequently fail in real production environments, and distills two context engineering principles that determine agent reliability.
Finding the "React philosophy" of the agent era: why architectural principles matter more than scaffolding
Looking back at the evolution of web front-end engineering, there is a highly instructive timeline. HTML was born in 1993. For the next twenty years, countless developers struggled through raw HTML, CSS, and spaghetti-style DOM manipulation scripts. It wasn't until 2013, when Facebook open-sourced React, that front-end development truly converged on a paradigm. By 2025, React and its derived frameworks dominate how modern web and client applications are built.
Why did React achieve this more-than-a-decade-long domination? Because it provided far more than scaffolding that saves a few lines of boilerplate; it established a rigorous engineering philosophy. When you choose React, you are forced to accept the constraints of "declarative UI," "unidirectional data flow," and "component-based state isolation." Any engineer today would take these constraints for granted as industry standards, but in the era of directly manipulating jQuery nodes, these principles were far from obvious.
Looking at large language models (LLM) and AI agent engineering from the vantage point of 2025, the industry is still in the wild-west stage of "hand-writing raw HTML and CSS and trying to stitch them into a good experience." If you want to run a 5-minute toy-level agent demo, the community has hundreds of tutorials and out-of-the-box scaffolding. But once you enter serious enterprise production, trying to keep an agent highly reliable across complex tasks lasting tens of minutes or even hours, the industry has not yet established a recognized architectural standard.
Oil's perspective supplement: Direct DOM manipulation vs. React's "declarative UI" and "unidirectional data flow"
- Early direct DOM manipulation (jQuery): Any script on the page could directly modify a button's text or hide a popup at any time. As projects grew and a dozen scripts directly modified UI elements simultaneously, when a page rendered incorrectly, it was hard to trace which piece of code corrupted the state.
- React's declarative and unidirectional data flow: The code no longer manually modifies page nodes everywhere; instead, state is centrally managed, and data flows unidirectionally from top to bottom. When state data updates, the UI automatically re-renders based on the current data.
Worse, several highly influential open-source projects—such as OpenAI's openai/swarm and Microsoft's microsoft/autogen—are actively pushing an alluring but often dead-end approach to building: multi-agent collaboration architectures (Multi-Agent Architectures).
Many teams, on the very first day of a project, eagerly draw an impressive organizational chart: one "product manager agent" to oversee everything, a "UI engineer agent" to write the front end, an "API engineer agent" for the back end, plus a "testing QA agent" to find faults. This anthropomorphic division of labor matches the management intuition of human companies, but in real LLM engineering, it often creates fragile, error-prone systems.
The reliability foundation of long-horizon agents: from prompt engineering to "context engineering"
When you need an agent to run continuously over long-horizon tasks, call dozens of tools, and maintain coherent dialogue and state, the number-one enemy is compounding errors. If any intermediate step introduces a slight contextual deviation, each subsequent reasoning step and tool call will amplify that deviation exponentially, and the entire task chain quickly collapses.
The core determinant of long-horizon agent reliability is exactly context engineering.
Oil's perspective supplement: Compounding errors
Suppose an AI has 95% accuracy at each step. If a long task requires 30 consecutive steps, each depending on the previous result, the probability of all 30 steps being correct is $0.95^{30} \approx 21%$—meaning there is nearly an 80% chance of going wrong midway. That's why in long-horizon tasks, even one small omitted context detail will propagate and magnify through subsequent steps.
By 2025, mainstream base LLMs have astonishing single-shot reasoning capability. But even the world's smartest human expert, when handed a task without complete background materials, historical decision records, and causal context, cannot do the job well. The early chatbot era popularized "prompt engineering," which studies how humans describe a problem in a single conversation. In dynamically running agent systems, "context engineering" pushes this problem to a higher dimension: how does the system dynamically and automatically assemble the most complete and accurate context for each model reasoning step across ongoing multi-turn tool calls and state transitions? This has become the number-one core task for all AI agent engineers today.
To see how context engineering determines a system's fate, let's look at the most popular and seemingly intuitive multi-agent splitting architecture in the community:
- An orchestrator agent receives the top-level task, decomposes it into multiple independent subtasks.
- The orchestrator concurrently launches multiple subagents (Subagent 1, Subagent 2, ...), each claiming its own subtask.
- After all subagents finish, the orchestrator collects the results and assembles them into the final output.

If the business scenario happens to contain several seemingly parallel modules, this "divide and conquer" architecture is nearly irresistible. But in real engineering practice, this architecture is almost surely unreliable.
An expensive game of telephone: cloning Flappy Bird as an example
Why does this seemingly clear division of labor collapse in production? Let's look at a concrete programming case.
Suppose you give the orchestrator a top-level task: "Write a Flappy Bird clone." The orchestrator thinks, splits the task in two, and dispatches to two subagents that don't communicate with each other:
- Subagent 1's instruction: "Build a continuously scrolling game background with green pipes and collision hit-boxes."
- Subagent 2's instruction: "Build a bird character controlled by the player moving up and down."
On the surface, these subtasks are clearly bounded and well-defined. But when each subagent finishes writing code in isolation, disaster strikes:
- Subagent 1, without seeing the global requirements of "Flappy Bird," sees "green pipes" and "scrolling background" and immediately thinks of Super Mario Bros. So it writes a side-scrolling land level with pixel-art tiles, pipes firmly planted on the ground, and uses tile-based static collision volumes.
- Subagent 2 only receives "write a bird that can move up and down." It has no idea this is an arcade game requiring gravity and an impulse jump with the spacebar. So it draws a realistic bird icon with SVG and binds it to the arrow keys (ArrowUp/ArrowDown) for uniform linear movement.
Finally, when the orchestrator receives these two code pieces, it faces a Super Mario-style ground-and-pipe map plus an SVG bird moving uniformly with arrow keys. The two code bases are completely mismatched in coordinate systems, render loops (requestAnimationFrame), physics engine assumptions, and visual style. No matter how the orchestrator patches, it cannot stitch these two misunderstanding-laden outputs into a playable Flappy Bird.
You might think this example is extreme, but if you carefully examine real-world software engineering tasks, almost every requirement hides dozens of similar implicit details.
Two golden principles of context engineering
Principle 1: Share context—and share the full execution trace, not scattered single instructions
Facing the Flappy Bird failure, many engineers' first reaction: "Can't I just copy the original user prompt to every subagent? If everyone knows we're building Flappy Bird, the green pipes won't become Super Mario."
This patch might work in a single-turn demo, but in real production-grade agent systems, it's far from enough. In production, tasks often build on dozens of multi-turn dialogues. Before the orchestrator decides how to split the task, it has usually already called file search tools (like grep or glob), read the project's package.json, inspected existing Canvas renderer code, and internally reasoned through and eliminated several infeasible approaches. Any tiny discovery during this exploration directly determines how subtasks should be interpreted.
If you only throw the final dry subtask prompt at the subagent, it loses all the preceding exploration context. This leads to the first golden principle of context engineering: Share context—and you must share the full agent execution trace (Full Agent Traces), never just isolated single message fragments.
So let's upgrade the architecture for the first time: when launching Subagent 1 and Subagent 2, pass the entire conversation history and tool call trace ("conversation & actions so far") to each subagent; after they finish, aggregate their work traces back to the orchestrator.

Unfortunately, even with full prior trace sharing, this concurrent subagent architecture remains unreliable.
Back to Flappy Bird. This time, Subagent 1 and Subagent 2 both read the full prior context and know they are developing Flappy Bird. But during their separate concurrent coding, they cannot see what the other is doing:
- Subagent 1, while implementing pipe scrolling, decides on its own to use a fixed 60 FPS step, sets the canvas size to 400 × 600 pixels, pipe spacing to 120px, and uses flat retro 8-bit pixel art.
- Simultaneously, Subagent 2, while writing bird physics, decides on its own to use deltaTime-based physics integration, assumes canvas height of 1080px, gives the bird an 80px jump per click, and uses modern vector flat rounded style.
When the two code pieces merge again, even though both were writing Flappy Bird, the bird's jump height cannot pass through the pipe gaps, the physics clocks are completely out of sync, and the visual styles clash. Why? Because every concrete action they take during execution contains large numbers of implicit assumptions that were not specified in the top-level instructions.
Principle 2: Every action carries implicit decisions; conflicting implicit decisions inevitably lead to bad outcomes
In software engineering, top-level specifications can never exhaust all implementation details. When an agent writes a line of code, defines a data structure, or chooses a coordinate origin, that action itself finalizes dozens of micro-architectural decisions. If two agents take actions independently at the same time, they are effectively making implicit decisions in parallel, unbeknownst to each other.
This is the second golden principle of context engineering: Actions carry implicit decisions, and conflicting decisions inevitably lead to bad results.
Walden Yan makes an emphatic engineering judgment: Principles 1 (sharing full traces) and 2 (avoiding conflicting implicit decisions) are so fundamental that in most scenarios it's not worth violating them for the sake of concurrency. As a default architectural discipline, you should outright reject any agent architecture that cannot satisfy both principles.
This sounds like a straightjacket, but in reality, within the strict observance of these two principles, there is still broad architectural design space.
From single-threaded linear architecture to "context compression LLM"
The simplest and most direct way to follow the two principles is to abandon fancy multi-agent concurrency diagrams entirely and return to a single-threaded linear agent.

In the single-threaded linear architecture, from task decomposition, executing subtask 1, executing subtask 2, to final integration and verification, the same agent proceeds sequentially along a continuous timeline:
- When the agent starts executing "subtask 2 (write the bird character)," its context window not only retains the original task decomposition trace, but also fully contains every line of code, parameter choice, and tool call result from the just-completed "subtask 1 (write pipes and background)."
- It can directly see that subtask 1 set the canvas to 400 × 600, pipe spacing to 120px, and named the collision interface
checkPipeCollision(birdRect). Therefore, when writing the bird code, it naturally aligns to the same physics constants, coordinate system, and visual style, completely eliminating conflicting implicit decisions.
For most short-to-medium-horizon engineering tasks, this seemingly simple single-threaded linear architecture is not only simpler to implement, but also far more reliable than complex multi-agent orchestration.
However, when task scale grows and execution extends to dozens of sub-phases, the single-threaded linear architecture hits a physical ceiling: context window overflow.

As subtask 1, 2, 3... accumulate, file contents, terminal error logs, and intermediate reasoning quickly fill the 128K or even 200K context window. This not only causes inference latency to spike and attention to scatter, but eventually triggers the model's maximum token limit directly.
Since you can't escape context bloat by splitting concurrent subagents, how does a truly long-horizon production system solve it? Cognition offers a battle-tested advanced architecture: adding a dedicated "context compression LLM" on top of a single-threaded backbone.

In this architecture, the agent's execution remains single-threaded and linear, avoiding concurrent writes when two actions are unaware of each other. After each staged subtask, the system calls a dedicated context compression LLM to condense the previously verbose raw conversation and tool call records into a dense summary block of "key moments & decisions."
This way, when the agent moves to the next subtask, it doesn't have to carry thousands of lines of stale terminal debug output from earlier phases, but all critical interface contracts, architectural decisions, global constants, and lessons learned from prior phases are retained in a compact compressed form in the context.
Walden Yan admits that getting this context compression LLM right is extremely hard. You must invest significant effort in defining, for a specific business domain, which information is "non-loseable implicit decisions" versus "search noise to discard." Inside Cognition, while developing Devin, the team even fine-tuned custom small models specifically for code-engineering scenarios to handle this context compression work.
To concretely compare the four architectures in engineering practice, we can organize their core characteristics:
| Architecture pattern | Context passing mechanism | Implicit decision consistency | Long-horizon scalability | Production reliability assessment |
|---|---|---|---|---|
| Isolated concurrent subagents | Only passes the decomposed single subtask instruction | Extremely poor (complete blind guessing) | High (naturally isolated) | Almost surely unreliable, only suitable for toy tasks with no coupling |
| Concurrent subagents with shared prior history | Shares history before the fork, isolated after fork | Poor (assumptions conflict during concurrent execution) | Medium (each accumulates after fork) | Still unreliable, merge stage easily triggers interface and style conflicts |
| Single-threaded linear agent | Continuously appends full conversation and tool traces | Excellent (later steps fully see earlier steps) | Limited (long tasks easily trigger context overflow) | Simple and highly reliable, default choice for short-to-medium tasks |
| Single-threaded with context compression | Full current workspace + compressed block of historical key decisions | Excellent (core decision chain aligned throughout) | Excellent (supports very long-horizon operation) | Highly reliable for long-horizon tasks, but compressor development and fine-tuning barriers are high |
Real production validation: Claude Code subagents and the evolution of the Edit Apply model
If you don't believe the theoretical reasoning, look at how the top production-grade coding agents as of mid-2025 architecturally practice these two golden principles. Walden Yan cites two representative industry cases.
Case 1: Why does Claude Code never let subagents write code in parallel?
Developers who have used Anthropic's terminal coding tool Claude Code may notice a detail: Claude Code does have a mechanism to spawn subagents (Subagent / Task tool). But does that mean Claude Code uses a multi-agent collaborative coding architecture?
Quite the opposite. If you look closely at how Claude Code operates, it strictly follows two iron rules:
- The main agent never modifies the workspace in parallel with a subagent.
- Subagents are almost exclusively used to answer read-only, sharply bounded exploration questions (e.g., searching a large codebase for where a function is defined or its call chain), and are never directly responsible for writing or modifying production code.
Why do the designers of Claude Code impose such restrained restrictions? Because they deeply understand the boundaries of context engineering: a subagent lacks the complete global modification intent in the main agent's head. If you let it directly modify code, it will inevitably introduce conflicting implicit decisions. If you release multiple concurrent subagents that write code, the entire codebase instantly descends into merge hell.
Restricting subagents to "read-only detectives" is actually a clever context offloading technique. When the main agent needs to figure out "where is the auth middleware defined in the project," a subagent might need to run a dozen grep and file reads to find the answer. By having the read-only subagent run those ten-some steps of needle-in-a-haystack search, and only returning a single definitive conclusion ("auth middleware is located at src/middleware/auth.ts line 42") to the main agent, the main agent avoids polluting its main context with dozens of screens of irrelevant search intermediate steps. This is, in a minimal engineering way, achieving the "context compression" mentioned in Figure 5.
Case 2: Why is the "big model writes instructions + small model modifies files" Edit Apply model dying out?
Another highly persuasive historical lesson comes from the Edit Apply Model architecture widely used by AI coding tools in 2024 (including early Devin, early Cursor versions, and various IDE plugins).
In 2024, many flagship models had strong reasoning but often made mistakes when directly outputting standard diff patches or line-number replacements—miscalculating line numbers, messing up indentation. The industry's common workaround was a "two-model relay":
- First, let a smart large main model (like
GPT-4orClaude 3.5 Sonnet) read the context and write a "how to modify this file" instruction in natural-languageMarkdownwith code snippets. - Then feed that
Markdowninstruction along with the original file to a fast, cheap small model (theEdit Apply Model), which rewrites the entire file and writes it to disk.
This is, at the micro level, a "dual-agent relay architecture." In real production runs, this seemingly reasonable pipeline became a hotbed of failures. The small model, not having participated in the main model's preceding multi-turn reasoning, cannot see the full trace behind the main model's modification decisions. If the main model's Markdown instruction contains even the slightest referential ambiguity (e.g., writing // ... keep existing validation logic ...), the small model frequently misinterprets the main model's intent, deletes code that shouldn't be deleted, or inserts new logic into the wrong branch.
By 2025, as base models' tool-calling and code-editing capabilities matured, mainstream coding agents abandoned this split "big model dictates, small model transcribes" pattern, and fully reverted to having the same main model directly complete the edit decision and code write in a single action. The decider and the executor merged into one, completely eliminating the context loss from cross-model relay.
Why not let multiple agents "meet and discuss" with each other?
At this point, many readers still favoring multi-agent architectures raise objections: "Human software teams also have multiple people writing code in parallel! If engineer A's code and engineer B's code conflict logically, people sit down, discuss, pull up a group chat, and reach consensus. Why can't multiple subagents also coordinate and align by sending messages to each other?"
This is exactly the vision many academic papers and multi-agent frameworks love to paint. But directly applying human team collaboration models to 2025's LLMs ignores a fatal premise: Humans have extremely high-density metacognition and key-point abstraction when communicating across individuals, and that is precisely the weakest point of current LLMs.
When two experienced human engineers align on an interface, they don't need to recite every line of code in their heads to keenly catch the 3 key boundary conditions where their assumptions might conflict, and within a few minutes of conversation they reach a contract. Today's LLMs lack both the metacognitive ability to actively realize "which of my implicit assumptions might conflict with the other agent," and the ability to efficiently synchronize deep context in a long multi-party group chat.
If you force two subagents, each with tens of thousands of tokens of history, to "negotiate to resolve conflicts" through natural language dialogue, you'll find they either fall into polite empty agreement or lose focus in a long back-and-forth. The final reliability is far lower than having a single-threaded agent do both things sequentially from beginning to end.
Walden Yan is not entirely pessimistic about the future of multi-agent systems. He believes that the premise for multi-agent practicality is solving the underlying problem of "high-fidelity context transfer and active negotiation across agents." Ironically, almost no one in the industry is truly working on this hard cross-agent context synchronization problem; everyone is just building fragile multi-agent toys by simple message concatenation.
In fact, the key to multi-agent collaboration lies hidden in the evolution of single-threaded agents—only when we first perfect high-density communication, active clarification, and context compression between a single agent and a human engineer will reliable agent-to-agent collaboration naturally unlock.
Before that, when you next build a production-grade AI agent system, resist the urge to draw a sprawling multi-agent org chart: hold the single-threaded continuous context, respect the implicit decisions behind every action, and invest 80% of your engineering effort into context filtering, offloading, and compression.
After reading this, remember these three things
- Beware the "divide and conquer" multi-agent trap—in real production tasks, simply splitting tasks among multiple parallel subagents that each work in isolation is almost surely doomed to produce unstitchable fragments due to inconsistent implicit assumptions.
- Hold fast to the two golden principles of context engineering—first, when sharing context, you must share the full execution trace (
Full Agent Traces), never just isolated single instructions; second, every action carries unspoken architectural decisions, so you must architecturally prevent multiple write actions from happening in parallel without mutual awareness. - Replace blind concurrency with "single-threaded backbone + context compression"—prioritize single-threaded linear architecture to ensure decision continuity; for context overflow in long-horizon tasks, offload search noise with read-only subagents (as Claude Code does), or introduce a dedicated
Context Compression LLMto distill key moments and core decisions.
This article is compiled from the "Oil Book" AI practical notes series by 欧呦 (Oil 欧呦).