AI Agent Architecture: From Message Routing to Closed-Loop Learning

    This article compares two core AI agent architectures: centralized message routing and closed-loop learning systems. It explains why message routers lose context between turns, how closed-loop agents persist and retrieve state across sessions, and the practical differences in state management, memory, tool extensibility, and operability. It also offers guidance on migration, selection, and running agents reliably on the cloud.

    1. The Technical Question Behind the Hype: Why “Next-Generation Assistants” Keep Appearing

    Every few weeks, the open-source community releases a new batch of agent projects with nearly identical marketing claims: smarter, more autonomous, and seamlessly portable. For developers, the marketing narrative is not what matters. What matters is whether these projects fix the structural flaws of the previous generation at the architecture level. Shifting the focus from product comparison to architectural evolution makes the evaluation criteria much clearer: whether context can be accumulated, whether tools are extensible, whether state is retrievable, and whether failures can be reused.

    2. Architecture Type 1: Centralized Message Routing

    The core of an early agent is a message routing layer. It receives messages from various instant messaging channels, parses them uniformly, calls a large language model, and routes the result back to the original channel. The flow can be summarized as:

    1. Message ingress → Parsing and intent recognition → Model call → Tool execution → Response routing → Message egress

    The advantages are clear: the structure is simple, deployment is easy, horizontal scaling is straightforward, and the learning curve for teams is low. The limitations are equally obvious. Every conversation turn has an independent context, tool execution ends when it finishes, and no artifacts are accumulated. Users repeat background information, the system repeats the same mistakes, and the marginal benefit of long-term use approaches zero.

    3. Architecture Type 2: Closed-Loop Learning Systems

    Another design splits the agent into three subsystems that can evolve independently:

    1. ┌──────────────────────────────┐
    2. │ Agent main loop (dialog and scheduling) │
    3. └──────────────────────────────┘
    4. │ │ │
    5. Prompt builder Tool registry Session store
    6. │ │ │
    7. Context assembly Toolset grouping Structured + full-text retrieval

    The key difference is the “closed loop”: execution results are written back to storage and retrieved when the next prompt is built, forming a cycle of use, accumulation, and reuse. In engineering terms, this usually involves three things. First, the prompt builder dynamically trims context based on the current task instead of stuffing all history into the window. Second, the tool registry groups tools by toolset and loads definitions on demand to save tokens. Third, the session store uses structured tables plus a full-text index so that history can be recalled by both keywords and semantics.

    4. Substantive Differences Across Four Dimensions

    1. State management: stateless routing vs. persistent sessions. The former loses memory on restart, while the latter can carry tasks across sessions.
    2. Memory and retrieval: whether a retrievable history layer exists determines the success rate of long-cycle tasks.
    3. Tool extensibility: moving from “a few hard-coded actions” to a “registry plus toolsets” means new capabilities do not require changes to the main loop.
    4. Operability: a closed-loop system must additionally account for storage growth, retrieval quality, privacy, and cleanup policies.

    5. A Rational View on Migration and Selection

    “One-click migration” is essentially a format conversion of configuration, memory, and credentials. It is an engineering convenience and does not prove architectural superiority. For selection: centralized routing is sufficient for multi-channel customer service and notification scenarios; closed-loop learning is more suitable for scenarios that require long-term companionship and continuous accumulation of project knowledge. During implementation, start with small-scale validation and compare the “first-turn success rate” with the “tenth-turn success rate” on the same set of tasks. Only the latter truly reflects the value of accumulation.

    6. Filling Engineering Gaps on the Cloud

    Regardless of which architecture you choose, production requires common capabilities: use a container platform to host the stateless main loop, object storage to save sessions and artifacts, a message queue to smooth peaks and decouple channel integration, logging and monitoring with alerting to observe call chains and failure rates, and a key management capability to host credentials. Baidu AI Cloud offers corresponding products in these common categories, which can be combined as needed to take an agent from “runs” to “operable, auditable, and extensible.”