跪拜 Guibai
← All articles
AI Programming · Agent · LangChain

Breaking a Monolithic AI Research Agent into a Multi-Agent System with LangGraph

By chaors ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Multi-agent architectures promise modularity but frequently collapse under coordination overhead. This walkthrough shows a concrete, incremental migration path from a monolithic LangGraph agent to a supervised multi-agent system, with measurable improvements in testability, traceability, and code organization, while explicitly acknowledging when MAS is the wrong call.

Summary

The original DeepResearchSystem ran its entire pipeline inside one LangGraph state graph, which violated single-responsibility principles and made testing, reuse, and debugging difficult. The refactor introduces a Multi-Agent System (MAS) with three specialized subgraphs: a main supervisor that handles planning and HITL routing, a research agent that runs the query-search-critique loop, and a writer agent that now follows an outline-draft-review-polish workflow with structured critic feedback and revision loops.

Code organization improves sharply: the research and writer subgraphs become independently mockable, reusable across different applications, and produce clear hierarchical traces in LangSmith. The writer agent gains a dedicated critic that returns structured JSON feedback with severity ratings, and a routing function that either sends the draft back for revision or advances it to final polish once quality thresholds or max revision counts are met.

The piece also grounds the design choice in the broader MAS debate, citing the “Why Do Multi-Agent LLM Systems Fail?” paper’s 14 failure modes and arguing that coordination overhead often cancels out the gains of adding agents. The practical takeaway is a “single first, then split” engineering heuristic: start with one agent, measure where it breaks, and only then introduce additional agents with a clear justification.

Takeaways
Three specialized subgraphs replace a single 500-line graph: a supervisor for planning and HITL, a research agent for the search-critique loop, and a writer agent for outline-draft-review-polish.
The writer agent now runs a structured revision loop where a critic returns JSON feedback with severity levels, and a router decides whether to revise or proceed to polish based on score and revision count.
Subgraphs are independently mockable and reusable; the research agent can be dropped into a customer-support or competitive-analysis workflow without pulling in the full system.
LangSmith traces gain a clear subgraph hierarchy, making long-chain debugging easier than the flat traces of the original monolithic graph.
MAS adoption follows a “single first, then split” rule: establish a single-agent baseline, identify the specific bottleneck, and add one agent per bottleneck rather than preemptively splitting.
Coordination overhead in multi-agent systems often cancels out performance gains; the paper “Why Do Multi-Agent LLM Systems Fail?” catalogs 14 failure modes and three fatal pitfalls.
Conclusions

Refactoring to MAS is framed as an engineering discipline problem, not an AI capability problem; the driver is code organization, testability, and team-scale development cycles, not better model output.

The writer agent’s outline-draft-review-polish pipeline mirrors a human editorial workflow and introduces a structured critic that produces machine-readable feedback, which is a practical pattern for any system that generates long-form content.

The explicit comparison table between single-agent and MAS architectures surfaces concrete metrics like file line count, mock cost, and trace structure, which are rarely quantified in MAS discussions.

The article’s conclusion that MAS should only be adopted with a clear justification, and that single-agent baselines should come first, pushes against the common hype of adding agents for their own sake.

Concepts & terms
MAS (Multi-Agent System)
An architecture where multiple autonomous AI agents with specialized roles collaborate to solve a complex task, coordinated by an orchestration layer rather than a single monolithic agent.
Supervisor + SubGraph pattern
A LangGraph orchestration pattern where a main supervisor graph manages state routing and HITL interrupts, delegating business logic to independent subgraphs that the supervisor treats as black-box nodes.
HITL (Human-in-the-Loop)
A mechanism that pauses an automated agent workflow to wait for human approval or input before proceeding, commonly used for plan confirmation or sensitive actions.
LangSmith
A tracing and observability platform for LangChain and LangGraph applications that visualizes agent execution as hierarchical traces, aiding debugging of multi-step and multi-agent workflows.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗