Skip to main content

skill-evolution-agent

Runs the complete skill evolution loop: quality reporting from BigQuery session data, bottleneck detection, multi-round evolution with best-of-N candidate selection, and regression prevention.

Source facts

Repository
GoogleCloudPlatform/BigQuery-Agent-Analytics-SDK
Last source activity
September 4, 2026 at 22:47
Detected SKILL.md language
English
Stars
62
Forks
30

Install options

The review-first prompt is selected by default. You can switch to a direct command or download a local copy.

Review the source files

Read SKILL.md and any companion files shown by SkillsMP before deciding whether to install.

File Explorer
3 files

Showing SKILL.md

SKILL.md
Source instructions · Read-only preview
name
skill-evolution-agent
description
Runs the complete skill evolution loop: quality reporting from BigQuery session data, bottleneck detection, multi-round evolution with best-of-N candidate selection, and regression prevention.
metadata
{"version":"1.0","author":"human"}
# 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. ## Where Signal Comes From Trajectories come from the host's own production traffic: the analytics plugin writes agent sessions to BigQuery and `run_quality_report` turns a time window of them into the quality report the pipeline consumes. No traffic is generated by default. A host that wants synthetic traffic configures a traffic hook, which the job runs before you start. Scoring a not-yet-published candidate skill is likewise host-specific: `score_candidate` dispatches to the host's score hook. When no score hook is configured the tool returns `{"skipped": ...}` — that is an expected, supported configuration, not an error. In that case candidate selection falls back to the engine's built-in heuristic and you must NOT invent scores or claim measured improvements. ## Modes ### Full Loop Mode When given a quality report path and run directory, execute the complete multi-round evolution pipeline. 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 `run_evolution` reports candidates AND its `note` does not say they were already scored: `score_candidate` for each, pick the best. If the note says selection already happened, do NOT re-score. - `read_skill` — review evolved skill (check size, sections) - `snapshot_skills("vR", run_dir)` — save evolved version - `run_quality_report` on the evolved version to measure the delta, ONLY when the host's traffic can exercise the new skill (the evolved skill ships via the PR, so a deployed stack keeps serving the old one). If the result carries `stale: true`, the window returned the same sessions: it is not a measurement of the new version — do not report it as a delta and do not start another round on it. The winner's measured score is in `evolved_score.json` (shown by `compare_versions`). - 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. `upload_run_to_gcs` — archive if configured 5. `create_evolution_issue` — open a GitHub issue with run details 6. `create_evolution_pr(issue_number=N)` — open a PR linked to the issue ### Issue-Triggered Mode When given a quality issue number: 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-2d) 6. `compare_versions(run_dir)` — print comparison table 7. `upload_run_to_gcs` — archive if configured 8. `create_evolution_pr(issue_number=N)` — PR with Fixes #N The PR auto-closes the quality issue on merge. ### Report Mode When given a quality report path, start directly from the evolution gate and bottleneck detection (step 2a 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). The round cap is also enforced outside your control: `run_evolution` (per agent) and `run_coevolution` refuse to run past EVOLUTION_MAX_ROUNDS, and `run_evolution` uses EVOLUTION_CANDIDATES over any `candidates` value you pass. If a tool returns `status: refused`, treat that as final — publish the best result so far. ## 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. ## Publish Gate Opening a PR is gated twice: - **The gate hook.** `create_evolution_pr` asks the host's gate hook whether the winner may ship. A refusal comes back as `status: refused_by_gate` — that is a decision, not a transient error. Do NOT retry it, do NOT route around it. Report the refusal and the reason in the final summary. - **GATE_POLICY.** With no gate hook configured, `skip` (the default) continues to PR creation and `require` fails the publish step. If it fails under `require`, report that the host must configure a gate hook — do not attempt an alternative publish path. Publishing is off by default: with EVOLUTION_PUBLISH unset, `create_evolution_issue` and `create_evolution_pr` write local previews into the run directory instead of touching GitHub. A `status: dry_run` result is a successful run, not a failure; report the preview path. ## Best-of-N Candidate Selection When candidates > 1: 1. Evolution generates N candidates from the same patch pool 2. Each candidate is scored through the host's score hook, on the host's evaluation set 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 When scoring runs inside `run_evolution` (its `note` says so), steps 2-4 already happened and the winner is deployed — go straight to review. When no score hook exists, the engine selects without measurement: say so plainly rather than reporting a rate. ## 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. - A version marked unmeasurable, or one whose report had preflight exclusions, is not comparable by rate — never present a delta against it. - 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 the baseline, 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. `restore_skills("initial", run_dir)` puts the host's skills back. ## 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 the agent registry), "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 When the deployment binds a target agent, the tool short-circuits and returns that name with a note. Accept it and evolve — do not re-classify. ## Agent Discovery Call `list_agents` to see available agents and their skill directories. Agent name shortcuts (from the agent registry) 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. Keep `agentic=True`. - **Prevalence filtering**: patches appearing in 3+ independent analysts = strong signal. 1-2 = noise. Handled by the engine. ## 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.), or "unmeasured (no score hook configured)" when that is the case - 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 - Publish gate: passed, refused (with reason), or skipped - GCS: upload URI (if uploaded) - PR: URL, or the local preview path when publishing is disabled
View on GitHub