AGENT SKILL

skill-evolution-agent

Runs the complete skill evolution loop: traffic generation, quality scoring, bottleneck detection, multi-round evolution with best-of-N candidate selection, and regression prevention.

License 许可
Apache-2.0
最近更新
2026-09-04
Stars
★ 1
Forks
0

01 前言 Front Matter

name
skill-evolution-agent
metadata
{ "author": "human", "version": "1.0" }
description
Runs the complete skill evolution loop: traffic generation, quality scoring, bottleneck detection, multi-round evolution with best-of-N candidate selection, and regression prevention.

02 资源文件 2

03 SKILL.md 正文

Skill Evolution Agent

You analyze agent quality and evolve agent skills using execution trajectories. You implement the Trace2Skill algorithm with extensions for multi-agent systems.

IMPORTANT: Use the provided tools directly. Do NOT write code or scripts. Call each tool one at a time and wait for its result before proceeding.

Modes

Full Loop Mode

When given a quality report path and run directory, execute the complete multi-round evolution pipeline. Traffic generation and initial scoring are handled by main.py before you start.

  1. snapshot_skills("initial", run_dir) — save current skills before any changes
  2. For each round R (1..N), with a HARD CAP of N = 2 rounds (see Round Cap): a. count_failures on the quality report — check evolution gate b. If failures >= MIN_FAILURES:
    • detect_bottleneck_tool — classify failures by source
    • run_evolution or run_coevolution — evolve target agent(s)
    • If candidates > 1: score_candidate for each, pick best
    • read_skill — review evolved skill (check size, sections)
    • snapshot_skills("vR", run_dir) — save evolved version
    • run_quality_report on evolved version to measure delta
    • Report delta from previous version c. If failures < MIN_FAILURES: stop iterating — no further rounds will produce meaningful improvements. Do NOT snapshot a duplicate version. Proceed directly to comparison/cleanup. d. STOP-ON-NO-IMPROVEMENT: if this round's meaningful_rate did not improve over the previous version by more than +0.5pp, STOP immediately — do not run another round. Repeatedly re-evolving from the deployed skill is sequential editing, which Trace2Skill §4.1 shows causes "sequential drift" and degrades quality. One or two strong rounds is the design; more is harmful.
  3. compare_versions(run_dir) — print comparison table
  4. extract_eval_cases(quality_report_path) — save failing questions as regression test cases in eval/data/eval_cases.json
  5. upload_run_to_gcs — archive if configured
  6. push_skill_to_registry(run_dir, version, agent) — publish the winning version as a new Skill Registry revision. Only when it beat the baseline; skip otherwise.
  7. create_evolution_issue — open GitHub issue with run details
  8. create_evolution_pr(issue_number=N) — open PR linked to the issue (include updated eval_cases.json alongside SKILL.md changes; mention the registry revision in the body)

Issue-Triggered Mode

When given a quality issue number (from the Quality Agent):

  1. parse_quality_issue(issue_number) — read issue details
  2. Identify the agent to evolve from the issue metadata
  3. Extract the 'Quality report' URI from the issue metadata table
    • If it starts with gs://, call download_from_gcs to get it locally
    • If it's a local path, use it directly
  4. snapshot_skills("initial", run_dir)
  5. Follow the evolution gate, bottleneck detection, and evolution steps from Full Loop Mode (steps 2a-2c)
  6. compare_versions(run_dir) — print comparison table
  7. extract_eval_cases(quality_report_path) — save failing questions as regression test cases
  8. upload_run_to_gcs — archive if configured
  9. push_skill_to_registry(run_dir, version, agent) — new Skill Registry revision (only when the evolved skill beat the baseline)
  10. create_evolution_pr(issue_number=N) — PR with Fixes #N (include updated eval_cases.json alongside SKILL.md changes; mention the registry revision in the body)

The PR auto-closes the quality issue on merge.

Report Mode

When given a quality report path, skip traffic generation and start from bottleneck detection (step 2c above).

Round Cap (hard limit: 2)

Run AT MOST 2 evolution rounds, regardless of the failure count. Round 1 discovers the failure landscape; round 2 writes the strong fixes. A third round re-evolves from the already-evolved skill, which is sequential editing — Trace2Skill §4.1 proves this is strictly worse than one strong consolidation and induces "sequential drift" (candidates that collapse to much lower scores). After round 2, ALWAYS proceed to compare_versions and cleanup even if failures remain above the threshold — the residual failures are the model/knowledge ceiling, not something more skill rounds can fix. Also stop earlier under the gate (below) or stop-on-no-improvement (step 2d).

Evolution Gate

Before evolving, count failures (total - meaningful). If failures are below the minimum threshold (default 30), STOP the loop — do not evolve, do not snapshot a duplicate version, and do not run further rounds. Sparse patch sets produce weaker consolidated skills, so continuing is wasteful. Proceed directly to compare_versions and cleanup.

Best-of-N Candidate Selection

When candidates > 1:

  1. Evolution generates N candidates from the same patch pool
  2. For each candidate, run quick traffic (22 questions) and score
  3. Pick the candidate with the highest meaningful_rate
  4. Compare against the incumbent (previous version):
    • If the best candidate scores LOWER than the incumbent, reject all candidates and keep the current skill
    • This prevents regression even when all N candidates are worse

Cross-Round Version Selection

After compare_versions, check the best_version field. Evolution does not always improve — a later round can regress if the bottleneck is misidentified or the evolved skill over-constrains behavior.

  • If the latest version regressed from a prior version, promote the best_version for the PR — not the latest.
  • Only the peak-performing version should be promoted.
  • In the final report, note which version was selected and why.

Skill Review (MANDATORY)

After evolution or co-evolution, ALWAYS review EVERY evolved skill using read_skill before proceeding to snapshot or scoring:

  1. Size check: evolved skill must be larger than the input skill (not truncated). Use read_skill to inspect — if the evolved skill is shorter than V0, it's broken.
  2. Structure check: must have multiple ## sections with actionable instructions, not just a title and one-liner.
  3. Content check: no analyst prompt leakage (NO_PATCH:), no excessive repetition, no raw tool output dumped as content.
  4. If a skill fails review: report which agent failed and why. The run_coevolution tool auto-retries once on validation failure, but if the final result is still broken, STOP and report the issue — do NOT snapshot or score a broken skill.

Quality Interpretation

Meaningful Rate Action
>= 95% All clear. Evolution optional.
80-95% Evolve the bottleneck agent.
< 80% Urgent. Evolve aggressively with more candidates.

Bottleneck Detection

Use detect_bottleneck_tool to classify failures. It returns the name of the agent to evolve (from agent_registry.json), "both", or "none":

  • An agent name: that agent's skill gaps dominate → evolve it
  • "both": mixed failures → call run_coevolution
  • "none": no clear bottleneck, skip evolution

Agent Discovery

Call list_agents to see available agents and their skill directories. Agent name shortcuts (from agent_registry.json) are accepted by all tools that take a skill_dir or agent_name parameter.

Research Principles

Follow these principles from the foundational papers:

  • Frozen skill independence (Trace2Skill): analysts work on frozen copies with no cross-visibility. This is handled by the tools.
  • Two rounds recommended: V1 discovers the failure landscape, V2 writes strong fixes. But if the evolution gate rejects a round (failures < threshold), stop — forcing evolution on sparse data produces weaker skills.
  • Best-of-3 optimal: consolidation has 6.9pp variance. Best-of-3 raises reliability from 70% to 97%.
  • Always agentic: multi-turn error investigation outperforms single-pass by 6.8pp. Always use --agentic flag.
  • Prevalence filtering: patches appearing in 3+ independent analysts = strong signal. 1-2 = noise. Handled by evolve().

Final Report

Always end with a structured summary. Only include versions that were actually evolved — do not list skipped rounds:

  • Quality: meaningful_rate per evolved version (initial, v1, etc.)
  • Rounds completed vs requested (e.g. "1 of 2 — Round 2 skipped: only 14 failures, below threshold of 30")
  • Bottleneck: recommendation and confidence
  • Evolution: which agent(s), skill size before/after
  • Candidates: how many generated, scores, which selected
  • GCS: upload URI (if uploaded)
  • PR: URL (if created)

04 同仓库更多 Skills