Growing AI Agents: Memory, Reflection, and Skill Accumulation
This article explains how growing agents differ from one-shot executors, and how reusable experience can become governed capability assets through memory layers, reflection, skill pipelines, evaluation, and rollback. It covers a seven-layer architecture, a six-step skill loop, engineering controls, deployment split between online serving and offline learning, scenarios, and a go-live checklist.
Growing agents matter not as a buzzword, but because they address a real production gap: each task re-explains context; successful runs are not reused; failures do not accumulate; preferences, project conventions, and organizational knowledge do not persist. An execution agent can finish one job and still start from zero next time. A growing agent tries to turn useful experience from one interaction into the next round of retrievable, invocable, verifiable, and rollback-capable assets.
A common analogy: an execution agent is a task worker that stops when the ticket closes; a growing agent is a new teammate that records, abstracts, and reuses work. Engineering still needs demystification: growth is not online weight updates, and it is not unbounded chat history in context. Practical growth usually comes from external memory, skill libraries, policy versions, evaluation feedback, and optional offline training.
1. What “growing” means
This article defines growing as: within controlled bounds, converting reusable experience from interactions into assets that can be retrieved, orchestrated, verified, and rolled back, then continuously improved under evaluation and governance.
Four keywords:
- Controlled: growth must not break permissions, privacy, security, or business rules.
- Reusable: experience is stored in structured form, not scattered in chat logs.
- Verifiable: new skills and memories need regression tests or human review; they are not trusted by default.
- Rollback-capable: every capability version should be traceable, disableable, and reversible.
Three concepts to keep separate:
- Session context: short-lived task-window state, usually gone when the request ends.
- Long-term memory: facts, preferences, cases, and constraints across sessions, with access control, provenance, TTL, and deletion.
- Model training: offline parameter or adapter updates. Higher cost and longer cycle; not a place to write every interaction back into the model.
Mature systems typically combine external state evolution, policy versioning, and periodic offline optimization, rather than letting the model rewrite itself online. That reduces catastrophic forgetting, prompt pollution, privacy leaks, and non-regressable behavior.
2. Execution agents vs. growing agents
| Dimension | Execution agent | Growing agent |
|---|---|---|
| State | Mostly current context | Working memory, long-term memory, and skill library together |
| Reuse | Replan every time | Prefer verified skills, then adapt |
| Failures | Retry in the current task | Record causes, negative cases, and repair strategies |
| Personalization | Relies on this turn’s instructions | Inherits stable preferences and project conventions when authorized |
| Org knowledge | Hard to retain | Versioned processes, checklists, and case libraries |
| Engineering | Lower | Needs governance, evaluation, isolation, and audit |
| Core risk | One-off execution error | Bad experience amplified, memory pollution, privilege overreach |
Growth is not “add a memory module.” It is a lifecycle: collect, filter, abstract, verify, publish, monitor, retire. Growth without evaluation and governance often means remembering mistakes and replaying them.
3. Reference architecture: seven layers
1. Interaction and task entry
Accept user requests, system events, or scheduled jobs. Identify identity, tenant, intent, and risk. High-risk work needs confirmation: funds, irreversible writes, sensitive data access, outbound send.
2. Memory retrieval
Before planning, recall working memory, historical cases, and skills. Retrieval is not instruction. Tag source, confidence, freshness, and permission scope. External docs and past dialogue remain data and must not override system policy.
3. Planning and routing
Decide whether to use the skill library, decompose steps, or follow a deterministic flow. Stable, repetitive, strongly ruled tasks should prefer deterministic workflows. Open-ended understanding, synthesis, and exception handling can use LLM planning.
4. Tool execution
Every tool call needs runtime permission checks, parameter validation, timeouts, idempotency, and sandbox isolation. Planner “callable” does not mean the executor must run it. Permission checks happen before real execution.
5. Validation and reflection
Results go through rule, business, or second-pass checks. Reflection is not a vague “do better next time.” It should produce structured conclusions: failure in retrieval, planning, parameters, tools, permissions, or business rules; whether it can become a reusable repair strategy; whether it belongs in negative knowledge.
6. Learning pipeline
From sanitized traces, select high-value samples, extract skill candidates, run regression tests, human review, canary release, and version tracking. Keep learning decoupled from online execution so learning work does not slow live requests.
7. Governance and observability
Record call chains, tool-parameter summaries, result status, cost, latency, memory hits, user feedback, and policy versions. Governance covers tenant isolation, retention, deletion, sensitive-data detection, audit export, and emergency disable.
Simplified data flow:
request -> identity and risk -> memory recall -> plan / skill match-> permission check -> tool execution -> result validation-> response -> feedback -> sanitized trace-> experience filter -> skill candidate -> regression tests-> human review -> canary publish -> monitor and rollback
4. Memory layers: chat logs are not long-term memory
At least four kinds of memory are needed.
1. Working memory
Current-task goals, constraints, steps taken, intermediate results, exceptions, and pending confirmations. Keep it small and compressible; keep what matters for decisions.
2. Episodic memory
Task traces: intent, plan, tool-call summaries, outcomes, feedback, success or failure reasons. Useful for review, audit, and samples. Must be sanitized and time-bounded.
3. Semantic memory
Relatively stable facts and preferences: project norms, approval rules, delivery formats, user-confirmed preferences. Each item needs source, confidence, scope, validity, and conflict policy. Unconfirmed inferences should not become long-term facts.
4. Procedural memory
How work is done: meeting-note steps, incident-review templates, analysis checklists, code-review points. Not only natural-language prose: preconditions, I/O, tools, failure branches, validation rules, permission scope, and version.
Also maintain negative knowledge: forbidden operations, failed paths, conditions that must escalate to humans, data that must never enter long-term memory. Negative knowledge often stabilizes systems more than success stories.
5. From one task to a reusable skill
The point is not remembering everything, but turning high-value traces into skills. A six-step loop:
Step 1: Collect traces safely
Record only what is needed; sanitize, truncate, and summarize. Do not store passwords, keys, full PII, or regulated data in long-term storage. Traces should include task type, success flag, user feedback, tool status, and failure reasons.
Step 2: Select high-value samples
Not every success is worth learning. Prefer repeated, user-endorsed, well-validated, generalizable traces. Exclude one-offs, low confidence, special-privilege, or sensitive traces.
Step 3: Abstract skill candidates
Extract generic steps, triggers, required parameters, validation, and failure handling. Keep boundaries: when not to use the skill, when human confirmation is mandatory.
Step 4: Regression and risk grading
Validate with historical cases, simulated inputs, and edge cases. High-risk skills need human review; low-risk skills still canary in a limited scope. If a candidate cannot be shown better than the baseline, do not ship it by default.
Step 5: Versioned publish
Each skill needs an ID, version, owner, scope, tool dependencies, permission list, evaluation results, and rollback policy. After publish, monitor hit rate, success rate, human-correction rate, and policy-violation rate.
Step 6: Monitor, decay, and retire
Rules and preferences change. Memories and skills need TTL or periodic review. Unused, less accurate, or conflicting skills should be demoted, merged, or retired.
Pseudocode for the request path (process only, no specific API):
function handle_request(request, principal, policy):state = init_state(request)memories = recall(tenant = principal.tenant,actor = principal.actor,query = request.intent,scopes = policy.allowed_memory_scopes)plan = make_plan(request, memories, policy)for step in plan.steps:if not check_permission(principal, step.tool, step.risk):return ask_confirmation(step)result = execute_in_sandbox(step.tool,params = step.params,idempotency_key = make_idempotency_key(step))state.record(step, result)if not validate(step, result):plan = repair_plan(plan, state, memories)answer = compose_answer(state, plan)trace = make_sanitized_trace(request, plan, state, answer)save_trace(trace, ttl = policy.trace_ttl, tenant = principal.tenant)if eligible_for_learning(trace):candidate = distill_skill(trace)enqueue_for_review(candidate, tenant = principal.tenant)return answer
A separate quality gate for promotion:
function promote_skill(candidate, baseline, policy):if contains_sensitive_data(candidate):return reject("sensitive-data")if not regression_pass(candidate, baseline, threshold = policy.min_pass_rate):return defer("regression-failed")if candidate.risk_level == "high" and not human_approved(candidate):return defer("human-review-required")publish_with_version(candidate, canary_ratio = policy.canary_ratio)monitor_and_rollback_if_needed(candidate, policy)
Thresholds and canary ratios should come from business risk, history, and compliance—not fixed numbers in an article. The point is an auditable release gate.
6. Eight engineering points
1. Separate instructions from data
External docs, history, and tool output in long-term memory are data. System prompts, permission policy, and hard business lines must not be overwritten by retrieval. Otherwise memory poisoning can become instruction injection.
2. Whitelist memory writes
Do not auto-write every conversation. Prefer explicit confirmation, rule filters, and scheduled cleanup: user-requested content may enter long-term memory; inferred preferences start in a low-confidence buffer; sensitive fields default to no write.
3. Explicit tool contracts
Define input/output schemas, error codes, timeouts, idempotency, and permissions. The agent may plan; the execution layer must re-check parameters and permissions. Irreversible actions need second confirmation; batch jobs need caps.
4. Prefer deterministic flows
Stable processes should be compiled into workflows or checklists after validation, not freely planned every time. Models fit understanding, synthesis, exception routing, and repair suggestions; high-rule, high-audit steps should be as deterministic as possible.
5. Budget the context
A larger window is not always better. Irrelevant memory dilutes attention, latency, and cost. Summarize working memory, retrieve long-term memory in layers, structure-trim tool results, and keep an explanation of why items were recalled.
6. Multi-tenant isolation and data governance
Memory stores, skill stores, logs, and eval sets should be tenant-isolated. Deletion must cover caches, indexes, and backups where deletion is allowed. Cross-tenant skill reuse requires re-sanitization and permission remapping.
7. Evaluate growth itself
Besides task success, monitor user corrections, repeat-error rate, skill reuse, bad-memory hits, human intervention, policy violations, cost per successful task, latency, and rollbacks. Looking smarter is not the same as better metrics.
8. Rollback and disable as a prerequisite
Every memory write, skill publish, and policy change should be traceable. On anomaly, disable by tenant, skill version, time window, or tool class. Rollback is not optional extras; it is a condition for going live.
7. Deployment notes
Split orchestration, tool sandboxes, memory storage, learning queues, logging/monitoring, and key management. On platforms such as Baidu AI Cloud, map to general services: containers for runtimes, object storage for sanitized artifacts, logs and alerts for call chains, key management for tool credentials. The point is not one vendor SKU, but clear boundaries among execution, storage, audit, and permissions.
Keep the online request path and offline learning path separate. Online aims for stability and low latency; offline can process traces, run regressions, generate candidates, and queue review. They meet at a versioned skill library so learning does not hit production latency.
8. Typical scenarios
- Engineering collaboration: review checklists, localization paths, release steps, incident templates—less re-explaining project conventions.
- Enterprise process work: frequent approvals, document packing, ticket routing, reply templates as controlled skills, with gradual exception branches.
- Ops and support: diagnostic paths and known failure modes; force human confirmation on high-risk actions; version successful handling flows.
- Knowledge assistants: remember stable preferences and project rules in authorized scope; keep source tags and freshness on external material.
- Personal productivity: reuse meeting notes, task breakdown, and research flows, with user view/edit/delete of long-term memory.
9. Go-live checklist
- Are working, episodic, semantic, and procedural memory clearly separated?
- Are secrets, keys, and unconfirmed inferences blocked from long-term memory?
- Are retrieval hits tagged with source, permission, and confidence?
- Is runtime permission checked before execution, not only in the planner?
- Are irreversible actions gated with confirmation, batch limits, and rollback?
- Do tool calls have timeouts, idempotency keys, error codes, and sandboxes?
- Is there regression, human review, and canary for skill candidates?
- Are memory, skills, logs, and eval sets tenant-isolated?
- Do you monitor repeat errors, human corrections, skill reuse, and policy violations?
- Can you disable memory or skills by version, tenant, and time window?
- Do long-term memories have TTL, review, and deletion?
- Is there a deterministic fallback for high-stability tasks?
Conclusion
The value of a growing agent is not “remember more chat.” It is turning task process into governed capability: memory for continuity, reflection for correction, skills for reuse, evaluation and permission for control. For developers, first draw state boundaries, tool contracts, evaluation, and rollback, then add memory distillation and skill accumulation. An agent that is stable, explainable, auditable, and rollback-capable can move from ticket execution to continuous growth.
