Growing AI Agents: Closed-Loop Learning and Memory Architecture
Most conversational assistants operate in a request-generate-discard loop, so validated preferences, troubleshooting paths, and proven procedures disappear when the context window closes. This article explains how a growing-agent architecture can extract reusable skills from successful traces, persist them in layered memory, and decouple planning, memory, tools, and model inference so experience remains searchable, versioned, auditable, and portable across model or infrastructure changes.
Growing AI Agents: Closed-Loop Learning and Memory Architecture
Mainstream conversational assistants work in a request-generate-discard-context loop. Once the window closes, preferences, troubleshooting paths, and verified operating steps are gone. This is not simply a matter of poorly written one-off prompts. The runtime fails to turn successful experience into searchable, versioned, auditable assets. The problem a growing agent must solve is precisely this: moving from a stateless calculator to an execution entity that accumulates working habits.
The Problem Is the Runtime Loop, Not Model Parameters
A linear agent path usually looks like this: understand the instruction, call tools, return a result. Task success or failure affects only the current reply; it does not change the default strategy for the next run. Users therefore repeatedly restate the same constraints: directory conventions, release windows, rollback conditions, and log fields. The model re-reasons every time, which increases latency and makes drift in details more likely.
Changing “done” into “done and leave behind executable memory” requires three capabilities at the same time. First, the system must extract stable steps from traces instead of dumping the entire conversation into context. Second, those steps must live in storage outside the session and survive restarts, machine changes, and model changes. Third, planning, memory, tools, and model inference must be decoupled from one another, so changing the underlying model does not require tearing down the skill library.
Closed-Loop Learning: From Traces to Skills
The closed loop should not trigger at every step. A safer point is after a task has been validated as successful: tests pass, a release completes, a query result matches expectations, or the user explicitly confirms. Failure traces are also valuable, but they should be labeled as counterexamples or items pending review, so incorrect steps are not written into default skills.
Extraction should use three layers rather than generating one long note.
- Trigger conditions: what intent, environment, and preconditions should activate this skill. If the conditions are too broad, the skill will fire incorrectly; if they are too narrow, it will never match.
- Execution steps: ordered actions, required parameters, checkpoints, and stop conditions on failure. Keep only repeatable decisions and remove one-off hostnames, secrets, and temporary paths.
- Boundaries and evidence: scenarios where the skill does not apply, operations that require human confirmation, and the signals used to judge success at the time.
The skill body is best described in structured plain text so it can be reviewed and diffed. Parameters should be placeholders rather than values hard-coded from one task. For example, a container release can be abstracted into image name, tag, target environment, health check path, and rollback strategy. Next time, only the variables are replaced, and reasoning focuses on the differences rather than writing the entire process from scratch.
Below is a skill skeleton that only illustrates the division of fields; it is not a proprietary format for any platform:
name: container-releasetriggers:- intent: release container service- requires: [image built, target environment declared]inputs: [image, tag, env, health_path]steps:- verify image digest matches tag- run health check in staging first- switch traffic in batches and monitor error ratestop_if:- health check fails repeatedly- error rate exceeds pre-release baselinenotes:- production switch requires human confirmation
The loading strategy should be “retrieve first, then plan.” When retrieval hits a valid version, the planner treats the skill as a prior and only fills in current parameters and exception branches. When there is no hit or the skill has expired, the system falls back to full reasoning and, after success, proposes writing a new skill. This shortens the routine path without letting outdated steps constrain new problems.
Persistence: Memory Must Be Layered, Not Just Long Context
Putting all history into context is costly, and old errors can be repeatedly activated. A clearer approach is to layer memory by lifetime and purpose.
- Session state: the current goal, selected parameters, and unfinished steps. It can be discarded when the session ends.
- Working memory: stable user or team preferences, such as default branch strategy, naming conventions, and notification channels. Changes must be traceable.
- Skill library: validated processes with version, author, scope, and recent success rate.
- Evidence store: raw materials such as log snippets, check results, and change ticket IDs. Skills reference evidence but do not copy secrets or private text into the skill itself.
Storage can be implemented with general-purpose capabilities: skills and metadata in version-managed object storage or a database; retrieval using keyword plus vector indexes; audit trails in a logging service; and secrets only in a secret manager, with skills referencing names. Cloud platforms such as Baidu AI Cloud offer object storage, container platforms, logging, and monitoring/alerting that can support these layers; memory logic need not be bound to a single model service.
Before writing, apply redaction and the principle of least necessity: tokens, connection strings, personal data, and internal host details should not enter skills by default. Anything that can be parameterized should be parameterized. For permissions, personal preferences and team skills should be separated; production skills should be released through review rather than silently overwritten by a model.
Decoupled Architecture: Growth Should Not Be Tied to a Single Inference Implementation
If memory, tool protocols, and model calls are entangled in the same process, the skill library becomes invalid when the model is changed or scaled. It is better to define four clear boundaries.
The planner decides only whether to use a skill, which parameters are missing, and when to stop. It does not directly hold long-term storage. The memory service handles retrieval, versioning, and conflict merging. The tool runtime handles real side effects and returns structured results. The model provides language understanding and drafting only; it is not the sole source of truth.
Tool descriptions should remain stable: name, input schema, risk level, and idempotency. Skills reference tool names and schemas, not one-off temporary script paths. This allows skills to migrate across execution environments as long as the tool contract still exists.
Conflicts are normal. If two skills both claim they can handle “release,” they should be ranked by trigger-condition precision, environment tags, and recent validation results, not simply by file recency. Expired skills should be downweighted rather than physically deleted, so it remains possible to audit why a decision was made at the time.
Quality, Cost, and Risk
Automatic accumulation can easily turn accidental success into a standard. Before launch, at least four things should be done: replay desensitized historical tasks to see whether a skill reduces repeated reasoning without increasing failures; require human confirmation for high-risk actions; assign an owner and review cycle to every skill; and monitor false-trigger rate, rollback count, and human veto rate. These metrics are for detecting degradation in the skill library, not for chasing an artificially high automation ratio.
On cost, a skill hit can reduce multiple rounds of reasoning, but retrieval, storage, and review also have costs. Low-frequency, highly creative tasks are not worth writing into skills. Tasks that are high-frequency, have stable steps, and have clear failure costs are the ones worth accumulating.
The goal of a growing agent is not to make the model “remember everything.” It is to move validated working methods out of the session and into governable assets. The closed loop produces candidate experience, layered storage lets it survive restarts, and architectural decoupling keeps that experience from being held hostage by any single inference implementation. Together, these three make an assistant evolve from a stranger into a collaborator that truly understands the engineering habits of the environment.
