跪拜 Guibai
← All articles
Agent · LangChain · LLM

The Five Patches That Turn a Chatbot Into an Agent

By 小月土星 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

The difference between a chatbot and an agent is not model size—it is whether the model has tools, memory, and retrieval. Products like Claude Code and Cursor prove that wiring these five modules to a capable LLM produces a system that can execute multi-step work unattended, and the message-loop architecture with Promise.all concurrency is the difference between a demo and something that ships.

Summary

LLMs ship with five inherent defects: they are stateless, cannot execute actions, lack private knowledge, have a knowledge cutoff, and cannot orchestrate long tasks. An Agent fixes each one with a corresponding module—Memory, Tool use, RAG, MCP, and Skills—transforming a model that can only chat into one that can remember, act, retrieve, and plan. The formula is MECE: every gap gets exactly one patch, and together they cover the full distance from suggestion to execution.

The core mechanism is a relay-style message loop where the LLM itself acts as the dispatch center. When it decides a tool is needed, it stops generating text and emits a tool_calls list; the runtime executes the function and returns a ToolMessage keyed by tool_call_id. That ID is load-bearing—without it, an agent running multiple async tools cannot match results to requests, and the context collapses. A dependency analysis layer that groups independent tool calls into Promise.all turns a working agent into a fast one.

Claude Code validates the formula in production: it is simply LLM + fs + CLI, with the tool mechanism pushed to its limit. The tech stack to build your own—Node.js, NestJS, LangChain, LangGraph, and MCP/RAG/Skills—is mature and layered cleanly between traditional backend concerns and AI orchestration.

Takeaways
An LLM has five fatal gaps—statelessness, no execution, no private knowledge, a cutoff date, and inability to chain long tasks—and Agent architecture patches each with a dedicated module.
The six modules (Memory, Tool, RAG, MCP, Skills) are mutually exclusive and collectively exhaustive; miss one and the agent fails in its corresponding scenario.
The LLM itself is the dispatch center, not an external rule engine. It reads tool descriptions in natural language to decide when to call what, so description quality directly controls accuracy.
Tool invocation follows a relay loop: the LLM stops and emits tool_calls, the runtime executes and returns a ToolMessage with a tool_call_id, and the LLM resumes with the result. The ID is the only thing preventing context chaos under concurrent calls.
Independent tool calls must run through Promise.all, not serially. Five independent calls take max(t1…t5) instead of t1+t2+t3+t4+t5, a multi-fold speedup that separates usable agents from good ones.
Claude Code is LLM + fs + CLI—proof that the formula is complete enough to build a shipping product.
A practical stack is Node.js + NestJS (backend) + LangChain (single-agent abstraction) + LangGraph (multi-agent orchestration) + MCP/RAG/Skills (capability extensions).
Conclusions

The claim that the five defects are MECE is a strong architectural assertion: it implies the formula is both necessary and sufficient, and any agent that works must implement all five modules in some form.

Making the LLM the dispatch center rather than a hard-coded router is a double-edged bet—it keeps the architecture simple but makes the system's reliability hostage to prompt and description quality, which are inherently brittle.

The tool_call_id mechanism is underappreciated. Most agent failures under concurrent tool calls trace back to ID mismanagement, not model intelligence.

Promise.all as a performance optimization is obvious in isolation, but the article's call for a dependency-analysis layer inside the tool-execution loop is a concrete engineering step most toy agents skip.

Concepts & terms
MECE (Mutually Exclusive, Collectively Exhaustive)
A principle from management consulting meaning categories that do not overlap and together cover all possibilities. Applied here to argue the five Agent modules are both necessary and sufficient.
Tool Call Relay Loop
The message pattern where an LLM emits tool_calls instead of text, the runtime executes the function and returns a ToolMessage keyed by tool_call_id, and the LLM resumes generation with the result. The ID is critical for matching async results to requests.
Promise.all
A JavaScript method that takes an array of Promises and runs them concurrently, returning when all have resolved. In Agent tool execution, it collapses serial wait times into the duration of the slowest call.
LangChain / LangGraph
LangChain is an LLM development framework providing unified model interfaces, tool abstractions, and message management. LangGraph extends it for multi-agent orchestration when a single agent cannot handle complex workflows.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗