Self-Evolving Agents: Skill Generation and a Memory Feedback Loop
Agents that start every task from a blank context keep repeating the same reasoning and the same mistakes. This article explains a controlled learning loop—capture outcomes, distill reusable skills, retrieve and revise them—what it actually solves, what it should not overclaim, and the governance required before production.
Agents that start every task from a blank context keep repeating the same reasoning and the same mistakes. When developers say “if it learns this slowly, don’t bother,” they are usually not complaining that the model is too small. They are pointing at experience that never survives across sessions. Self-evolution is not mysterious: it is a controlled learning loop—observe results, abstract reusable steps, write skills, then retrieve and revise them on later tasks. This article takes an engineering view of what that loop can solve, what it must not overstate, and the controls you need before you ship it.
The pain is not “ask again”—it is that experience never becomes an asset
Execution-oriented agents are good at turning a goal into tool calls: read code, run tests, change configuration, return logs. That is often enough inside a single task. After the session ends, the root cause of the error, the workaround, and the environment constraints disappear together. The next time a similar stack trace appears, the agent starts again from document search and trial and error. At the organization level it is worse: personal debugging notes sit in chat logs, cannot be reused by other sessions or colleagues, and have neither versions nor invalidation conditions.
So “permanent memory” that simply dumps every conversation into a vector store quickly becomes noise. What is valuable is distilling a successful fix into a skill with clear boundaries: matching symptoms, preconditions, steps, verification, and rollback on failure. Skills are retrievable, reviewable, and retireable assets—not an ever-growing pile of chat excerpts.
The learning loop: generate, use, evaluate, revise
The loop has four steps. Each should be auditable.
Capture. When a task finishes or stalls, record the goal, key observations (error summaries, environment differences, paths already tried), and whether the goal was met. Keep only facts that affected decisions. Do not write secrets, tokens, or raw private text into skills.
Generate. From a successful path, the model drafts a skill: trigger conditions, steps, expected signals, and cases where it must not apply. Drafts are candidates by default. They must not immediately override production behavior.
Validate. Confirm the steps are repeatable with a minimal reproduction or a regression check. Operations that cannot be validated automatically are marked for human confirmation. Failed validation is demoted to a note and stays out of the default executable set.
Revise. If the same symptom returns and the old skill no longer works, append a version instead of silently rewriting history. Record why it changed, the scope it applies to, and the rollback point. “Don’t make the same mistake twice” only has engineering meaning if the hit is a verified version, not unaudited improvisation.
Skills need not be bound to a vendor API. A structured document is enough:
id: retry-flaky-integration-checksymptoms: intermittent timeout on an integration check; business assertions still passsteps:- confirm the timeout is in an external dependency, not the assertion- isolate and rerun that check with a limited retry count- if it still fails, collect dependency latency before changing business codeverify: rerun passes and no new assertion failuresdeprecated_when: dependency timeout thresholds or network policy have changed
Skill optimization needs a budget and constraints
Automatic optimization easily drifts into “longer every edit.” Set hard limits: a maximum number of steps per skill, no plaintext secrets, no undeclared destructive actions, and no promotion of a one-off path into a general rule. Prefer tightening trigger conditions over stacking branches. If validation is still unstable after two revisions, stop auto-evolution and close the case with a human.
Retrieval should match on symptoms and constraints, not only nearest-neighbor semantic similarity. A high-confidence call of the wrong skill is more dangerous than having no skill. After a hit, run precondition checks: environment, version, and permissions still match the skill’s assumptions. If they do not, drop the skill and log the miss for the next revision.
Personal preference memory should stay modest. Remembering language, repo conventions, and release windows across sessions reduces repeated clarification. Preference is not authorization. Production changes, data export, and privilege escalation still need explicit confirmation. “It knows you better” must not become silent approval.
Always-on runtime and multiple channels solve reach, not intelligence
Hosting the agent in a long-running compute environment, with instructions arriving from messaging or workplace apps, means a task is not tied to whether a personal laptop is on. Architecturally: a channel adapter owns identity, sessions, and delivery; the agent runtime owns planning, tools, and the skill library; state lives in durable storage. As channels grow, do not copy memory at every entry point. Share one skill library and one audit log, isolated by user or tenant.
24×7 only means the process can keep accepting work. It does not mean unattended arbitrary change. Queues, timeouts, concurrency limits, and idempotency keys still matter. Long tasks should be inspectable, cancellable, and retryable without repeating side effects.
Swappable models and a fallback chain
Execution quality depends on the model, but the workflow should not be locked to one upstream. In practice, split “chat model, tool calling, long-context summarization” into configurable routing: a primary model for planning, a fallback only when the main path times out, is rate-limited, or is unavailable. On switchover, be explicit about the capability gap. A fallback may be weak at complex tool orchestration; shrink the action space—status reporting and safe retries, not automatic production config changes.
A fallback chain guarantees continued response, not identical quality. Routing, timeouts, and circuit breaking belong in configuration and monitoring so silent degradation is visible. Self-hosted or cloud models are both fine; the point is secret hosting, call audit, and quotas—not a hardcoded endpoint in business code.
How executors and orchestrators should split work
Executor agents fit bounded work: run checks in a given repo, follow a runbook for a known alert, summarize logs. An orchestrator maintains goals, the skill library, and subtask assignment, and hands concrete steps to one or more executors. Do not fuse them into one unbounded process. The orchestrator may decide which class of skill to invoke, whether to parallelize, and whether failure escalates to a human. Executors may only perform allowlisted actions. Even when many workers are scheduled, blast radius stays limited by tool permissions and approval policy.
“Managing other agents in reverse” without identity, quotas, and result checks only amplifies failure. Each subtask needs an input/output contract and a completion criterion. The orchestrator accepts or rejects against that criterion, not a natural-language “done.”
Maturity: auto-evolution does not fix install and compatibility
A complete self-evolution feature does not replace runtime maturity. System dependencies, container permissions, egress policy, and mismatched tool versions still fail at install time. Early incompatibility and defects are normal. Pin runtime versions, use least-privilege images, ship skills separately from the program, and make upgrades rollbackable. Writing a fix into a skill does not replace compatibility tests. A skill describes business or troubleshooting steps; it is not a promise of infinite OS compatibility.
Before go-live, at least check: skill writes go through a review queue; memory is tenant-isolated and deletable; tool calls default to read-only and writes require a second confirmation; logs trace to a skill version; model-failure degradation matches intent. On a cloud platform such as Baidu AI Cloud, those pieces can sit on ordinary containers, object storage, message queues, logs, and alerting: skills and audit in object storage or a database, task events on a queue, runtime state in monitoring—without welding evolution logic and infrastructure into an inseparable monolith.
A practical rollout order
Pilot a frequent, verifiable, low-damage scenario first—for example read-only troubleshooting and test reruns—not automatic production edits. Manually curate a few high-quality skills, then turn on candidate generation. Candidates enter the default retrievable set only after validation. Keep a switch to disable automatic revision. Expand the skill domain only when mean time to handle repeated issues drops and false-invocation rate is acceptable.
The conclusion is specific: self-evolution does not replace engineers. It turns verified solutions into versioned, retrievable, rollbackable skills so an agent can reuse correct experience across sessions. Memory, multi-channel access, and model fallbacks address continuity, reach, and availability. Only inside permissions, audit, and validation do they avoid turning one lucky success into the next automatic incident.
