AI Agent Core Patterns Explained: Reflection, Tool Use, Planning, and Multi-Agent Collaboration
This article breaks down the four core patterns of AI agents—reflection, tool use, planning, and multi-agent collaboration—and explains how each one turns a language model from a one-shot answer generator into a reasoning and execution engine. You will see how a basic agent skeleton (model, instructions, tools, and state/memory) supports these patterns, along with minimal implementation examples, key engineering constraints such as stopping conditions and tool safety gates, and a practical adoption path that starts with controlled scenarios and adds observability, sandboxing, and parallel execution as needed.
Introduction: From One-Shot Answers to Iterative Execution
The defining trait of a traditional large language model is that a single forward pass produces a complete answer. This works well for open-ended Q&A, text polishing, and similar tasks. But it quickly falls short when a task requires multiple steps, depends on real-time external information, needs quality checks on intermediate results, or calls for division of labor across roles.
In engineering terms, these gaps usually come down to four missing capabilities: no self-correction, no access to the outside world, no ability to produce and distribute artifacts, and no way to advance subtasks in parallel. Agent patterns are a systematic response to exactly these four gaps. They turn the language model from an “answer machine” into a “reasoning and execution engine,” using task decomposition, tool calls, result validation, and role coordination to convert complex goals into a controllable execution flow.
It is worth stressing that agents do not make the model “smarter.” They give the model a work loop. A usable agent system typically has four parts: the model (reasoning and generation), instructions (goals and boundaries), tools (connections to external capabilities), and state and memory (intermediate artifacts and the basis for decisions). All four patterns below are different ways of orchestrating this same skeleton.
Pattern 1: Reflection — Review Output Before Returning It
Reflection turns “generate — review — revise” into a closed loop. Think of a content production workflow: a writer rereads a draft before submitting it, checking facts, testing the argument, and fixing the conclusion. An agent can do the same, catching its own errors—or having a dedicated reviewer role catch them—before returning a result to the caller.
The minimal implementation is a two-step loop: first generate a draft, then review it and produce actionable feedback, then feed that feedback back to the generator to produce a revised draft. Whether to keep looping depends on predefined stopping conditions, such as a review score crossing a threshold, two consecutive rounds with no substantive improvement, or hitting the maximum iteration count.
# Illustrative code: a generate -> critique -> revise reflection loopdef generate(model, prompt: str) -> str:return model.chat(prompt)def critique(model, task: str, draft: str) -> str:return model.chat(f"Task: {task}\nDraft: {draft}\n""List factual errors, logical gaps, and improvement points, ""ordered by severity, with specific revision suggestions.")def refine(model, draft: str, feedback: str) -> str:return model.chat(f"Rewrite based on the feedback below, keeping the facts unchanged:\n"f"Draft: {draft}\nFeedback: {feedback}")def reflect_loop(model, task: str, max_iter: int = 3):draft = generate(model, task)for i in range(max_iter):fb = critique(model, task, draft)if "no major issues" in fb:breakdraft = refine(model, draft, fb)return draft
There are three engineering points to keep in mind. First, the review instruction must demand actionable feedback; otherwise the model tends to produce vague filler like “suggest further optimization” that cannot be acted on. Second, reflection has diminishing returns and a risk of self-reinforcing bias—the model may repeatedly confirm its own mistakes—so set an iteration cap and, in critical scenarios, bring in external validation (rule checks, unit tests, retrieval comparison). Third, reflection multiplies cost, so enable it only for high-value outputs, or use a lightweight “review first, then decide whether to revise” strategy.
Pattern 2: Tool Use — Connect the Model to the Real World
Tool use addresses the boundary of the model’s knowledge and the boundary of its execution ability. At the interface level, a tool usually has three elements: a name with a semantic description, an input parameter structure, and a return format. The model selects a tool based on task semantics, fills in parameters, parses the response, and folds the result into subsequent reasoning.
# Illustrative code: tool registration and invocation (pseudo-interface)TOOLS = {"search": {"desc": "Retrieve real-time information", "params": ["query"]},"calc": {"desc": "Perform precise numeric calculation", "params": ["expression"]},"render": {"desc": "Generate a chart file", "params": ["spec"]},}def call_tool(name: str, **kwargs):if name not in TOOLS:raise ValueError("Unregistered tool")return TOOLS[name]["impl"](**kwargs) # impl is provided by the runtime environment
The key design constraint is this: a tool description must state “when to use it,” not just “what it does.” Keep parameters as flat and explicitly typed as possible so the model does not make mistakes on nested structures. Control the size of returned results—summarize long text before feeding it back—so the context is not crowded out. In addition, every tool call needs timeouts, retries, and permission boundaries. Write operations (publishing, deleting, paying) should require human confirmation or a second check. This is the most important safety gate as an agent moves from read-only to write-capable.
Pattern 3: Planning — Decompose First, Then Execute
The planning pattern replaces the one-shot answer with “produce a plan first, then land it step by step.” The typical approach is to have the model output a task list first: goal, subtasks, dependencies, and acceptance criteria. Execution then follows the plan, and after each step the agent re-evaluates whether the remaining steps need adjustment.
There are two common orchestration styles. The first is fixed decomposition, suited to stable workflows such as data processing pipelines. The second is dynamic replanning, suited to high-uncertainty scenarios where execution gets blocked and the agent returns to the plan layer to change the path. The deciding criterion is simple: whether subtask results are predictable. If they are, use fixed orchestration for stability and cost advantages; if not, use replanning for robustness.
The plan itself should also be validated. In practice, a plan is required to meet a few conditions: every subtask has a clear deliverable, dependencies form no cycles, and each step can be completed within a limited number of tool calls. This avoids the “the plan looks complete but cannot be executed” kind of spinning.
Pattern 4: Multi-Agent Collaboration — Division of Labor and Checks and Balances
Multi-agent collaboration starts to pay off when a task needs different perspectives or different permissions. Three topologies are common: supervisor-style (one coordinator assigns tasks and aggregates results), pipeline-style (upstream output becomes downstream input), and peer-negotiation-style (multiple roles debate and converge on a conclusion).
The real benefit of multi-agent systems is not just parallel speedup, but the checks and balances that come from role isolation: separating the generator from the reviewer significantly reduces self-confirmation bias, and giving different roles different tool sets and permissions shrinks the single-point risk surface. The cost is higher context synchronization and conflict resolution overhead, so keep the number of roles within what is necessary and name a single owner responsible for converging on the final result, avoiding diffused accountability.
Implementation Advice: Start with Controllable Scenarios
The recommended path is incremental: use reflection first to improve the quality of individual outputs, then connect read-only tools to obtain real-time information, then use planning to handle multi-step tasks, and finally introduce multi-agent collaboration only when there is a genuine need for division of labor. Each stage should come with observability: write intermediate steps, tool calls, and token consumption to a logging service, and set dual thresholds for quality and cost through monitoring and alerting.
If you need elastic execution and isolated runtime, you can rely on a container platform to host tool sandboxes, use object storage to hold intermediate artifacts, and use a message queue to decouple long-running tasks, achieving genuine parallel progress. In related practice at Baidu AI Cloud, such capabilities are typically assembled from general-purpose cloud product categories, so teams can freely choose based on their own tech stack.
In summary, the essence of agent patterns is converting “model capability” into “system capability”: reflection provides a quality loop, tool use connects to the outside world, planning provides an execution skeleton, and multi-agent collaboration provides division of labor and checks and balances. Only when the four are layered together can a language model reliably take on long-chain tasks in real business settings.
