AI Agent Architecture: An Evolution Roadmap and Engineering Practice Guide

    This article traces the evolution of AI agents from rule-based automation to bounded autonomy, and breaks down the four core modules of a modern agent: perception, brain, action, and memory. It explains how reasoning and planning work together, how to design tool interfaces with narrow contracts and clear side effects, and how to manage short-term and long-term memory. It also covers the main engineering pitfalls amplified by large language models, including tool-amplified hallucinations, cumulative error over long chains, and runaway cost, along with practical mitigations and recommendations for starting from controllable scenarios.

    1. From Automation to Autonomous Intelligence: A Necessary Redefinition

    For the past few years, the industry has largely understood “agents” as workflow automation: given explicit rules and fixed inputs, a system executes tasks along predefined branches. This approach is highly efficient in scenarios with clear boundaries and slow change, but as soon as the environment produces an unexpected disturbance, someone has to re-orchestrate the workflow manually. The key difference of a new generation of agents (AI Agents) is autonomy: the agent first understands intent and perceives the environment, then decides its own path, and refines subsequent behavior based on feedback from results.

    A simple comparison makes the difference clear:

    1. Automation: if condition A then execute steps 1..N (path hard-coded in advance)
    2. Autonomous intelligence: goal G + environment state S -> reasoning and planning -> action -> observation -> plan refinement

    It is worth stressing that autonomy does not mean being out of control. What engineering pursues is “bounded autonomy”: goals that can be constrained, permissions that can be narrowed, processes that are observable, and results that can be rolled back. Autonomy without these four properties is a source of risk in production environments.

    2. Four Core Modules: Responsibility Boundaries and Coordination

    A modern agent can be abstracted into four modules that work together and form a closed loop: perceive input -> decide in the brain -> act to change the environment -> consolidate experience in memory.

    1. Perception: Turning the World into Computable State

    The perception layer normalizes multimodal input (text, images, audio, video, structured sensor data) into a representation the model can consume. There are three engineering priorities. First, modality alignment: timestamps and coordinate systems from different sources must be unified, otherwise later reasoning is built on false premises. Second, noise suppression: data from real environments is often incomplete and conflicting, so it needs confidence annotation and missing-value handling. Third, context trimming: the volume of perceived information often far exceeds the model’s context window, so it must be filtered and summarized by relevance rather than simply truncated.

    2. Brain: The Dual Engines of Reasoning and Planning

    The brain is usually made up of one or more foundation models and provides two key capabilities. Reasoning is logical analysis, causal judgment, and intent inference based on available information. Planning is breaking a broad, vague goal into ordered, executable steps and reordering them when blocked. In practice, planning quality often determines success more than model size does. Common approaches include:

    • Task decomposition: produce a high-level plan first, then refine it layer by layer into callable actions;
    • Reflection and retry: attribute failures, then generate alternatives instead of repeating the same action;
    • Multi-role collaboration: separate responsibilities such as retrieval, coding, and validation to reduce the impact of single-point hallucinations.

    3. Action: Extending Capability Boundaries Through Tool Calls

    The action layer changes the world by calling tools, which can be internal functions, external API services, data stores, office software, or physical devices. When designing a toolset, follow the principle of “narrow interfaces, strong constraints, explicit side effects”: each tool does one thing, parameter schemas are strictly validated, and write operations and read operations are authorized at different levels. An illustrative interface description:

    1. {
    2. "name": "query_order_status",
    3. "description": "Query status by order ID, read-only",
    4. "parameters": {
    5. "order_id": "string, required",
    6. "with_items": "boolean, default false"
    7. },
    8. "side_effect": "none"
    9. }

    4. Memory: Giving the System the Ability to Iterate

    Memory has two layers: short-term and long-term. Short-term memory holds intermediate conclusions and observations for the current task, and needs rolling compression because of context limits. Long-term memory holds experience, preferences, and domain knowledge, usually recalled through a hybrid of vector retrieval and structured indexing. The critical design is the write policy: not every interaction is worth keeping long-term, so entries should be filtered by success determination, reuse frequency, and recency, with support for expiration and correction to avoid reinforcing wrong experience over and over.

    3. Driving Forces and Common Engineering Pitfalls

    The natural language understanding, knowledge reasoning, and code generation capabilities brought by large models are the fundamental driver of this paradigm shift, and they mark a qualitative change in the generality of the “brain.” But the leap in capability also amplifies three pitfalls. First, hallucinations are amplified by tools: once a wrong conclusion triggers a write operation, the cost is irreversible. Second, errors accumulate over long chains: the more steps there are, the more success rates decay multiplicatively. Third, cost gets out of control: repeated reasoning and full-context injection quickly drive up spending.

    The corresponding mitigations include: introducing human confirmation and secondary validation for critical actions; splitting long tasks into verifiable segments with checkpoints; injecting context in layers (retrieving long-term knowledge on demand, summarizing short-term state); and building logs, metrics, and alerts across the whole chain so that every decision is traceable and replayable. When running on a cloud platform, this typically means using a container platform for elastic scaling, a message queue for task decoupling, object storage for intermediate artifacts, and logging and monitoring/alerting services for observability support. These are general capability categories and can be combined freely according to your own architecture.

    4. Implementation Recommendations

    Start from controllable scenarios, prioritizing business where errors are detectable and rollback is possible; narrow tool permissions to the minimum necessary, with write operations disabled by default; use an offline evaluation set to measure planning success rate and tool-call accuracy, then gradually loosen autonomy. In its own AI agent engineering practice, Baidu AI Cloud likewise emphasizes the implementation principles of “observable, constrained, and iterable,” which is consistent with the approach above: first make system behavior explainable, then talk about expanding the boundaries of autonomy.