AI Agent Architecture with Growth Capabilities: Closed-Loop Learning, Layered Memory, and Decoupling

    This article breaks down the three technical threads behind self-evolving AI agents: closed-loop learning that turns one-off tasks into reusable skills, three-layer memory that carries context across session boundaries, and architecture decoupling across the model, tool, memory, and policy planes. It also covers minimal skill file structure, memory governance, and common implementation pitfalls.

    Introduction: Why Agents Keep “Meeting You for the First Time”

    In the previous session, the agent had just helped you put together a complex environment deployment script. Close the window and reopen it, and it immediately returns to an initial state in which it knows nothing about you, forcing you to explain the project background all over again. This is not an isolated inference failure. It is a structural trait shared by most conversational agents today: the session is the lifecycle, and context is released as soon as the connection drops. In computational terms, they behave closer to stateless functions — the same input yields the same output, and nothing outside that input is retained.

    The engineering consequences are obvious. Every task requires paying the context-building cost again, operational experience already validated inside an organization cannot accumulate into an asset, and an individual user’s preferences and constraints are hard to turn into stable expectations. Over the past two years, the industry has begun pushing agents from “passive response tools” toward “digital counterparts that accumulate over time.” The technical mainline comes down to three threads: self-evolution, persistent memory, and architecture decoupling. This article takes a neutral technical view of how these three threads are implemented and what engineering constraints they carry.

    1. Closed-Loop Learning: Turning One-Off Tasks into Reusable Capabilities

    The execution chain of a traditional agent is linear: receive instruction → plan steps → call tools → return result. When the task ends, the chain is destroyed and experience resets to zero. Some popular agent frameworks in the industry have fairly rich skill ecosystems, but skill creation, review, and version management are still driven mainly by developers, so users cannot easily turn a problem they just solved into a system capability.

    The core change in closed-loop learning is adding a return path at the end of the chain: once a task is judged successful, experience extraction is triggered automatically, condensing the resolution process into a structured skill description file that later tasks of the same kind can load directly.

    A minimal skill file usually contains three parts: trigger conditions, execution steps, and caveats.

    1. ---
    2. name: container-service-deploy
    3. triggers: ["deploy containerized service", "release new image version"]
    4. parameters: [image_name, tag, replicas]
    5. ---
    6. # Execution Steps
    7. 1. Verify that image ${image_name}:${tag} can be pulled
    8. 2. Render the orchestration template and inject replica count ${replicas}
    9. 3. Perform a canary release and watch health checks
    10. 4. Roll back to the last stable version on failure
    11. # Caveats
    12. - Never overwrite default resource quotas directly in production
    13. - Confirm the rollback point is usable before making changes

    Two design points here are easy to overlook. First, the skill file must be a parameterized template, not a running log. Placeholders let the same piece of experience fit different projects, namespaces, and capacities, which is what makes reuse real. If what gets recorded is a specific command with fixed values, the second use requires manual rewriting and the accumulated value decays sharply. Second, trigger conditions need to be decidable. If the trigger description is too broad, it will fire on unrelated tasks; if too narrow, it degrades into a one-off script. In practice, trigger conditions are usually required to include both intent features and resource features.

    On top of the loop, the industry is also exploring automatic optimization of prompts and skill files. A common approach borrows from evolutionary search: maintain a set of candidate variants, select and mutate them based on feedback such as task success rate, and trade off between multiple objectives so that both success rate and cost are addressed. It is worth stressing that this kind of optimization does not depend on large-scale parameter training and can iterate through the inference API alone, but a human review step must be in place, merging changes through a change-review process so the agent does not gradually drift from the original intent without supervision.

    2. Three-Layer Memory: Carrying Context Across Session Boundaries

    Accumulated skills alone are not enough to constitute “growth.” An agent also needs to remember “you” and “the world state of this task.” The more common engineering practice is to layer memory, with each layer clearly distinguished by lifecycle and access pattern.

    The first layer is built-in persistent memory, which holds stable subject information: the user’s role, tech stack preferences, naming conventions, and prohibited items. It is small, read and written frequently, and requires strong consistency, so it is usually injected directly into a reserved section of the system prompt.

    The second layer is session retrieval memory, which holds conversation history and tool call traces, indexed by time or semantics and recalled on demand. It addresses referential questions like “that parameter mentioned in the last turn” and needs truncation, summarization, and relevance filtering, otherwise recalled content crowds out the effective context budget.

    The third layer is external memory plugins, which connect to an organization’s existing knowledge bases, ticketing systems, and code repositories, reading on demand through retrieval interfaces. Its value is keeping authoritative facts in the source system, with the agent acting only as a view layer, avoiding long-term inconsistency between memory copies and real state.

    The collaboration among the three layers can be summarized as: stable preferences go through writes, historical details go through retrieval, authoritative facts go back to the source. For implementation, it is advisable to attach source, confidence, and expiration time to memory entries and to support explicit forgetting — this is both an accuracy requirement and a compliance requirement.

    3. Architecture Decoupling: Replaceable, Observable, Rollback-Ready

    A growth-capable agent introduces a great deal of state and automated writes. Once tightly coupled with the runtime environment, the failure radius expands quickly. The goal of decoupling is to let four planes evolve independently.

    • Model plane: inference capability is replaceable, and business logic is not bound to a specific model;
    • Tool plane: capabilities are registered through standard interfaces, with parameter schemas and permission declarations described alongside each tool;
    • Memory plane: storage and retrieval are pluggable, and switching backends does not affect upper-layer policies;
    • Policy plane: learning trigger conditions, review rules, and budget caps are configured centrally.

    For implementation, the general product categories of Baidu AI Cloud can carry these planes: the container platform hosts the agent runtime and tool sandboxes, object storage holds skill files and version snapshots, the message queue takes asynchronous learning tasks and audit events, and logging plus monitoring and alerting provide call chain tracing and anomaly detection. For permissions, the least-privilege principle is recommended: grant write operations and high-risk tools separately, merge all auto-generated skills and prompt changes through review, and keep the ability to roll back to the last stable version in one step.

    4. Implementation Advice and Common Pitfalls

    First, define “success” before talking about learning. Without a decidable success signal, the loop only accumulates wrong experience; use passing tests, passing health checks, or human confirmation as the criteria.

    Second, control noise in memory writes. Not every conversation is worth keeping long term, so set a write threshold and a periodic cleanup policy.

    Third, factor cost into the design. Retrieval recall, skill matching, and automatic optimization all amplify call volume, so context budgets and call limits are needed.

    Fourth, keep the human in the loop. The boundary of automation should stop at “suggestions and drafts”; production changes, data deletion, and permission adjustments must be confirmed by a person.

    Conclusion

    The shift of agents from tools to digital counterparts hinges not on being smarter in a single answer, but on whether there is a channel for keeping experience. Closed-loop learning turns tasks into capabilities, layered memory carries context across session boundaries, and architecture decoupling makes the whole mechanism operable and rollback-ready. With all three in place, an agent genuinely “knows you better” the longer you use it.