Self-Evolving Agents: How Skills Are Generated and Optimized Autonomously

    This article explains how self-evolving agents turn completed work into reusable, versioned skills instead of relying on ever-longer prompts. It covers the five parts of a well-defined skill, the closed loop that extracts a skill from a single task, evidence-based optimization with regression samples, layered cross-session memory and its privacy risks, a product-agnostic component architecture, and the boundaries that still require human confirmation before production use.

    It solves something other than “better conversation” — it solves whether experience survives

    Most conversational agents work one request at a time. The more precise the prompt, the more stable the path; when the session ends, the decomposition strategy, the debugging experience, and the tool usage patterns usually disappear with it. The next similar task starts from zero: the goal, the constraints, and the acceptance criteria all have to be described again. What developers actually care about is rarely a few extra sentences from the model. They care about whether the system can remember what worked and push an ambiguous goal all the way to a deliverable result.

    A self-evolving agent treats “what has been completed” as an asset. During a task it decomposes, calls tools, reads errors, and corrects its path. After the task, it distills the practices that recurred and could be verified into skills, writes them into searchable memory, and reuses them in later sessions. “Evolution” here does not mean model weights automatically becoming a new model. It means the runtime capability structure grows thicker: the skill library, memory, and evaluation criteria all expand together. If unverified, accidental successes are written straight into long-term rules, the system will only fossilize its mistakes faster.

    What a skill actually is

    A skill is not a prompt saved offhand. It is a bounded unit of capability that contains at least five parts.

    • Trigger conditions: which goal, which input shape, which environment activates it.
    • Operating procedure: step order, permitted tools, input and output contracts.
    • Constraints: permissions, data scope, forbidden actions, timeouts.
    • Acceptance: what counts as success, and how to roll back or degrade on failure.
    • Evidence: which tasks it was distilled from, and whether the most recent validation passed.

    The structure can be plain:

    1. skill:
    2. name: fetch_and_chart
    3. when: need to sample a structured data source and produce a chart
    4. steps:
    5. - confirm fields, time range, and missing-value policy
    6. - pull a sample and validate the schema
    7. - aggregate, then output the chart and the data file
    8. tools: [http_get, file_write]
    9. never: [execute arbitrary external commands, write to undeclared directories]
    10. done_when: chart file exists and key metrics can be re-checked

    Defined this way, when the agent faces a vague instruction like “grab some data and visualize it,” what it retrieves is a procedure and an acceptance criterion — not a wish it cannot execute.

    From one task to a reusable skill

    Skill generation should be a closed loop, not a summary footnote appended when the conversation ends.

    1. Task understanding. Expand the vague goal into checkable sub-goals: where the data comes from, what the fields are, what the chart must show, how failure is determined. When information is missing, ask only about the critical gaps instead of pushing all responsibility back to the user.
    2. Planning and execution. The planner produces steps; the executor calls controlled tools. Every step retains its input, output, duration, and the verbatim error.
    3. Feedback and correction. Errors, empty results, and schema drift are all signals. The system should adjust parameters, switch data paths, or narrow the scope — not retry the same action without limit.
    4. Skill extraction. Write to the skill library only when the same kind of step converges across multiple attempts and acceptance passes. During extraction, strip the current path, temporary file names, and one-time credentials; keep only the transferable part.
    5. Versioning. A new skill is a candidate by default, carrying a version number, applicability preconditions, and counterexamples. Old versions are retained so rollback is possible.

    This is where “reduced dependence on prompts” comes from: the goal can stay vague, but the skill and its acceptance must be specific. Vagueness is absorbed by the skill library rather than absorbed by a longer system prompt.

    Optimization: making skills stronger, not bloated

    Optimization means changing a skill based on evidence, not rewriting its wording over and over.

    • Success rate: does the same class of task need less human intervention.
    • Cost: are step counts, tool calls, and failure retries going down.
    • Generalization: after switching data source or field names, does it still meet acceptance.
    • Regression: does the new change break previously passing tasks.

    A practical approach is to attach a small regression set to each skill: one normal path, one with a missing field, one with insufficient permissions. After optimizing, run the regression first, then decide whether to replace the default version. If a new version is faster on a single case but expands tool permissions, the merge should be rejected.

    Skills also conflict. For example, “repair automatically where possible” and “never modify configuration in production” cannot both apply unconditionally. Scheduling should select skills by environment, risk level, and the user confirmation policy, rather than stuffing every skill into the same context.

    What to watch for when memory spans sessions and entry points

    Long-term memory lets different sessions share experience, but it also widens the exposure surface. Layering is recommended:

    • Task memory: the current goal, decisions, and unfinished items; archived with the task by default.
    • Skill memory: de-identified procedures and acceptance criteria, reusable across sessions.
    • Environment memory: project structure, interface conventions, data locations; bound to the workspace and its permissions.
    • Preference memory: output format, language, risk tolerance; visible to and deletable by the user.

    Content that should not enter long-term memory includes credentials, personally identifiable information, internal addresses from one-time error stacks, and unconfirmed guesses. On retrieval, rank by relevance and freshness, and cap how many entries are injected into context so old skills do not drown out current constraints.

    A logical architecture that can actually be built

    Without depending on any specific product, the system can be split into clear components:

    • Planner: turns the goal into sub-tasks and a definition of done.
    • Executor: calls tools inside a sandbox with least privilege.
    • Observer: collects logs, exit codes, and data validation results.
    • Evaluator: scores against the acceptance criteria, separating “looks finished” from “verifiably finished.”
    • Skill library: versions, tags, activation conditions, and regression records.
    • Memory store: auditable writes, expiry, and deletion.

    In an enterprise environment, these components fit onto the existing engineering chain: code and artifacts go into version control, logs into a logging service, alerts into monitoring and alerting, large files into object storage, asynchronous work into a message queue, and runtime environments isolated with a container platform. The agent is only the orchestrator; it does not replace the permission system or the release process.

    If a team already uses the general compute, storage, and observability capabilities on Baidu AI Cloud, a self-evolving agent should likewise be onboarded as a controlled workload: identity, network, credentials, and audit follow the existing cloud boundaries instead of the agent building a second, unreviewable “universal permission” of its own.

    Boundaries: this is not yet stable, fully automated development

    Being able to run “decompose — code — fix based on errors — distill a solution” under a vague instruction only proves the loop exists. It does not prove that production changes can be delivered unattended. There are four common failure modes.

    • Error reinforcement: a workaround that bypassed validation once becomes a skill and is then copied in bulk.
    • Goal drift: sub-tasks succeed locally while the original acceptance criterion is missed.
    • Tool overreach: read or execution scope is widened in order to “fix the error.”
    • Unexplainable behavior: once skills stack up, nobody can say why this path was taken.

    Production use should therefore hold to a few rules: candidate skills are not auto-activated by default; actions that write production data, change permissions, or send things externally require human confirmation; everything written into memory must be traceable and switchable off. The evaluation set should include adversarial samples, such as instructions that are vague but dangerous, to confirm the system refuses rather than “creatively completing” them.

    What this means for the development workflow

    For an individual developer, the value is fewer repeated prompts: pattern-stable work like data cleaning, log triage, report generation, and test backfill can gradually become skills instead of a long prompt rewritten every time. For a team, the value is turning individual experience into a reviewable asset: skills have versions, acceptance criteria, and owners, and new members execute a skill instead of copying someone’s chat history.

    Adoption can proceed in three steps rather than chasing full automation from day one.

    1. Start with low-risk, verifiable tasks, such as read-only queries and local script generation.
    2. Write down the acceptance criteria and the prohibitions for each task class before allowing candidate skill extraction.
    3. Use regression samples and permission audits to decide whether a skill may become the default path.

    The meaning of self-evolution is therefore concrete: an agent can accumulate reusable, verifiable, rollback-capable skills during use, reducing its dependence on precise prompts — but that growth must be constrained by evaluation, permissions, and versioning. Without those constraints, autonomously generated skills simply swap uncontrolled prompts for uncontrolled memory.