AI Agent Architecture Evolution: From Message Routing to Closed-Loop Learning
This article compares two AI agent architecture patterns: centralized message routing and closed-loop learning systems. It explains how to evaluate an agent by three criteria—where state lives, how tools are registered and discovered, and whether execution results feed back into later decisions. You will see the trade-offs of each pattern, how prompt construction, a tool registry, and session storage work together, how result feedback enables learning, and the practical risks of migrating configuration, memory, and credentials across tools. It closes with selection guidance and a cloud deployment approach.
1. The Starting Point: Why “Next-Generation AI Assistants” Keep Appearing
Every so often, the open-source community releases a new wave of agent projects, each claiming to pick up existing configurations seamlessly while delivering stronger autonomy. For developers, the marketing pitch matters less than the architectural differences: is an agent a stateless forwarder that starts from zero in every conversation, or a stateful executor that accumulates experience and reuses it in later tasks?
The evaluation comes down to three questions: where state is stored, how tools are registered and discovered, and whether execution results flow back into the next round of decisions. The discussion below follows these three threads.
2. Architecture Type One: Centralized Message Routing
A typical implementation is a straightforward processing pipeline:
Message ingress → Message parsing → Model invocation → Tool execution → Response routing → Message egress
Its strengths are clear boundaries, easy horizontal scaling, and low adaptation cost when connecting multiple instant messaging channels. The limitations are equally clear:
- Session contexts are isolated from one another, so information cannot carry naturally across sessions;
- Execution ends as soon as a tool finishes, and its outputs are not persisted in a structured form;
- Extending capabilities requires invasive changes to the routing layer, making plugin governance difficult;
- There is no failure replay mechanism, so a single exception often invalidates the entire task round.
This architecture suits short interactions such as notification delivery and single-turn question answering, but not task-oriented work that requires long-cycle follow-up.
3. Architecture Type Two: Closed-Loop Learning Systems
Autonomous agent architectures typically split the system into three modules that can evolve independently:
┌──────────────────────────────────────────────┐│ Agent Core Loop ││ (main control flow for multi-turn ││ reasoning and action) │└──────────────────────────────────────────────┘│ │ │▼ ▼ ▼Prompt Construction Tool Registry Session Store(context assembly) (capability list) (structured persistence)
The responsibilities and engineering value of the three modules are as follows.
1. Prompt Construction Layer: Turning “Memory” into Usable Context
This layer dynamically assembles context before each round of reasoning, including system constraints, historical summaries, confirmed facts, and the current task description. The key practice is to compress information before injecting it, avoiding unbounded context growth. It also explicitly separates factual conclusions from speculative content, reducing the chance that the model treats an assumption as a conclusion.
2. Tool Registry: From Hardcoding to Discoverable Capabilities
A mature design abstracts tools into entries with metadata describing their purpose, input constraints, permission scope, and failure semantics. At runtime, a candidate subset is retrieved for the task at hand rather than handing the model every tool at once. As the number of tools grows, this on-demand recall significantly reduces incorrect invocations. Example structure:
{"name": "file_index_search","scope": "read_only","input_schema": { "query": "string", "top_k": "integer" },"failure_semantics": "retryable"}
3. Session Store: Making Retrieval a Default Capability
Pairing an embedded relational database with a full-text search index is a common industry practice: structured fields hold task state and execution traces, while the inverted index handles keyword recall over historical content. Three points matter in implementation: writes must be idempotent, sensitive fields must be encrypted or masked, and retention policies must be configurable. Otherwise storage grows rapidly and creates compliance risk.
4. How the Loop Actually “Learns”
The key to the loop is not storage but result feedback: after a task finishes, successful paths, failure causes, and human corrections are organized into searchable entries, which are recalled first when a similar task appears in the next round. Engineering-wise, it is advisable to introduce confidence scores and time decay so stale experience does not pollute decisions, and to keep a human review entry point so low-quality experience can be flagged and taken offline.
5. Real Risks of Configuration Migration
Migrating configurations, memory, and keys across tools looks convenient, but the risks are concentrated:
- Exporting credentials in plaintext creates a leak surface that is hard to trace; reissuing least-privilege keys is the better approach;
- Historical memory may contain outdated conclusions and needs revalidation after migration;
- When skill definitions are incompatible with the target runtime version, failures often surface only after a delay;
- The migration process should be rollback-capable and keep an audit log of operations.
6. Selection Guidance and Cloud Implementation
Choose a routing architecture for short interactions and notification-heavy needs; choose a closed-loop architecture for tasks that require long-cycle follow-up and multi-tool coordination. On the cloud, you can combine a container platform to host the runtime, object storage to hold artifacts, a message queue to decouple tasks, and logging plus monitoring and alerting services to observe the pipeline; the relevant general product categories from Baidu AI Cloud can serve as a reference for selection. It is advisable to start with a canary validation on a small set of real tasks, using task completion rate, number of human interventions, and average elapsed time as core metrics, then decide whether to scale up.
