Skill Generation and Optimization for Self-Evolving Agents

    This article explains how self-evolving agents turn successful task runs into retrievable, versioned skills instead of relying on one-shot prompts. It covers task memory, skill libraries, a planner-executor-memory-evaluator architecture, failure handling, evaluation metrics, and governance so similar fuzzy goals need fewer precise instructions over time.

    In enterprise R&D and data analysis, many tasks cannot be fully specified in one step. Users often give fuzzy goals such as “fetch data and generate a visualization” or “turn log anomalies into reusable checks,” and expect the system to decompose work, write scripts, read errors, and correct the path. Traditional conversational assistants put almost all constraints in the current prompt; when the session ends, the experience is gone. A self-evolving agent turns a successful run into a skill that can be retrieved, versioned, and re-evaluated, so later similar tasks depend less on exact wording.

    It is not about chatting better—it is about whether experience persists

    Self-evolution does not mean arbitrarily rewriting model weights in production. A more common and controllable meaning is that, without changing the base model, the system keeps accumulating task traces, tool-use patterns, and acceptance criteria, forming a capability structure for a given team. That typically includes three layers:

    1. Task memory: Keep goals, constraints, input/output examples, failure reasons, and the approach that was finally accepted, so the business context does not have to be restated from scratch.
    2. Skill library: Extract recurring workflows into skills with preconditions, parameters, steps, and rollback notes, rather than one long, unmaintainable prompt.
    3. Policy updates: Adjust retrieval, decomposition, and tool choice from execution results—for example, routing similar errors to a verified repair branch first.

    “Remembering” and “getting stronger” should mean observable behavior change: under the same fuzzy instruction, fewer steps, less rework, and more stable results—not a subjective sense that the model suddenly became smarter.

    From one execution to a reusable skill

    A complex task usually goes through goal clarification, planning, execution, observation, and acceptance. The key for a self-evolving system is a skill-candidate step after acceptance.

    When a task succeeds, the system should not save the whole conversation. It should extract trigger conditions, required inputs, prohibitions, tool or API categories, intermediate checkpoints, success criteria, and fallbacks on failure. For example, “pull structured data and chart it” can become: confirm data source and time range, validate field completeness, clean missing values, choose chart type, generate a repeatable script, and regress on sample data. The next time a fuzzy request appears, retrieval returns this skill instead of the model improvising every detail.

    When a task fails, record a structured failure class: insufficient permissions, schema change, timeout, results that violate business rules, or a plan that was too coarse. Only structured failure reasons make it possible to shorten trial-and-error on similar errors instead of retrying blindly.

    Skills should also be versioned. A new version must ship with a change note and regression cases; old versions stay so you can roll back if results go wrong. “Automatic optimization” without versions and tests only turns accidental success into permanent rules.

    Reference architecture

    Four kinds of components describe the system without tying it to a specific product:

    • Planner: Split a fuzzy goal into verifiable subtasks and mark which steps need human confirmation.
    • Executor: Call general capabilities such as a code runtime, data queries, file handling, and notifications, returning observations step by step.
    • Memory and skill store: Object storage for traces and artifacts; a searchable index for skill summaries. Sensitive fields should be redacted by default.
    • Evaluator: Score against acceptance criteria and decide whether to keep, revise, or drop a skill. Logs and monitoring alerts surface repeated failures and abnormal calls.

    A control-flow sketch (not a product API):

    1. goal = normalize(user_request)
    2. skill = retrieve(goal, constraints)
    3. plan = skill.plan if skill else draft_plan(goal)
    4. for step in plan:
    5. result = execute(step)
    6. if not result.ok:
    7. plan = repair(plan, result.error, known_fixes)
    8. if plan.exhausted:
    9. record_failure(); ask_human(); stop
    10. artifact = assemble(results)
    11. if evaluate(artifact, acceptance):
    12. propose_skill_update(trace, artifact)
    13. else:
    14. record_failure()

    Repair must be bounded by retry count, time, and permission budgets. Reading an error and making a local change fits syntax errors, missing fields, and repeatable run failures. It does not fit unbounded rewrite loops, and the agent must not expand data access on its own.

    Reducing dependence on precise prompts

    Three preconditions help:

    1. The environment is observable: Errors, exit codes, sample outputs, and checks feed back to the planner.
    2. The goal is testable: At least format, fields, order of magnitude, or business rules exist; otherwise the system cannot tell whether “looks done” is actually done.
    3. Skills are retrievable: Keys should include task type, data shape, and constraints—not only keyword match on full history.

    Then users can state business intent. The system fills default steps from skills and corrects the path from execution feedback. If no skill matches, it enters exploration, marks the result as a candidate, and promotes it only after evaluation. Exploration should have weaker permissions than production skills so unverified scripts do not touch production data.

    Evaluation and governance

    Skill quality should be measured on a regression set, not a one-off demo. Track at least: completion rate, human interventions, average retries, consistency with acceptance criteria, and degradation after reuse. Skills that break when data formats change should be down-weighted automatically.

    Governance should separate auto-adoption from human approval. Read-only analysis and draft generation can be persisted automatically. Writes to stores, outbound sends, permission changes, and deletes must keep confirmation points. Memory shared across sessions and entry points should be isolated by tenant, project, and role, with retention limits. Secrets, personal data, and internal addresses in traces should be stripped before storage.

    Skill text is itself an attack surface. Retrieved history must not override system constraints or tell the executor to ignore permissions or leak other tenants’ data. Treat skills as data, not as higher-priority instructions.

    A practical rollout order

    Do not start with fully automatic delivery. A safer sequence is: pick a class of tasks with clear boundaries, high repeatability, and low failure cost (for example report scripts, log grouping, and API sample cleanup); define minimal acceptance criteria and failure classes; persist only skills a human has confirmed; then widen the scope of automatic repair. Containers isolate each run; object storage holds artifacts; logs and alerts watch retries and unusual permission requests. If you use Baidu AI Cloud, apply the same isolation, retention, and audit practices rather than wiring unexplained automatic rewrites to production writes.

    The value of a self-evolving agent is turning successful paths under fuzzy goals into reusable, rollback-capable, auditable skills, then tightening later plans with execution feedback. It does not replace clear acceptance criteria and permission boundaries. Only when memory, evaluation, and governance are designed together does accumulated experience stay an asset instead of an uncontrolled historical burden.