evolving-ai-agents
Provides guidance for automatically evolving and optimizing AI agents across any domain using LLM-driven evolution algorithms. Use when building self-improving agents, optimizing agent prompts and skills against benchmarks, or implementing automated agent evaluation loops.
What this skill does
# Evolving AI Agents with A-Evolve
## Overview
A-Evolve is universal infrastructure for evolving any AI agent across any domain using any evolution algorithm with zero manual engineering. It represents all evolvable agent state as files (prompts, skills, memory, tools), runs iterative solve-observe-evolve cycles against benchmarks, and uses LLM-driven mutation to improve agent performance automatically.
**Benchmark results** (Claude Opus 4.6):
- MCP-Atlas: 79.4% (#1)
- SWE-bench Verified: 76.8% (~#5)
- Terminal-Bench 2.0: 76.5% (~#7)
- SkillsBench: 34.9% (#2)
## When to Use A-Evolve
**Use A-Evolve when:**
- Optimizing agent prompts, skills, or memory against a measurable benchmark
- Building self-improving agents with automated gating and rollback
- Evolving domain-specific tool usage and procedures through LLM-driven mutation
- Running iterative solve-observe-evolve loops to maximize agent performance
- Needing reproducible, git-versioned evolution history for every change
**Key differentiator**: Other frameworks _build_ agents; A-Evolve _optimizes_ them. It sits on top of any agent framework and makes it better through automated evolution.
**Do NOT use A-Evolve for:**
- Building multi-agent orchestration from scratch (use CrewAI, LangGraph)
- One-shot agent tasks with no iteration needed (use LangChain, LlamaIndex)
- RAG pipeline optimization (use LlamaIndex, Chroma)
- Prompt-only optimization without skill/memory evolution (use DSPy)
## Quick Start
### Installation
```bash
pip install a-evolve # Core
pip install a-evolve[anthropic] # With Claude support
pip install a-evolve[all] # All providers
```
### Three-Line Evolution
```python
import agent_evolve as ae
evolver = ae.Evolver(agent="swe", benchmark="swe-verified")
results = evolver.run(cycles=10)
print(f"Final score: {results.final_score}")
```
This copies the built-in SWE seed workspace, runs 10 evolution cycles against SWE-bench Verified, and returns the optimized agent.
## Core Concepts
### The Agent Workspace
All evolvable state lives as files in a workspace directory:
```
my-agent/
├── manifest.yaml # Metadata + entrypoint
├── prompts/
│ ├── system.md # Main system prompt (evolved)
│ └── fragments/ # Modular prompt pieces
├── skills/
│ └── skill-name/
│ └── SKILL.md # Reusable procedure with frontmatter
├── memory/
│ ├── episodic.jsonl # Lessons from failures
│ └── semantic.jsonl # General knowledge
├── tools/
│ ├── registry.yaml # Tool manifest
│ └── tool_name.py # Tool implementations
└── evolution/ # Managed by engine (metrics, history)
```
### The Evolution Loop
Each cycle follows five phases:
1. **Solve** — Agent processes a batch of tasks from the benchmark
2. **Observe** — Benchmark evaluates trajectories, producing (task, trajectory, feedback) triples
3. **Evolve** — Evolution engine mutates workspace files based on observations
4. **Gate** — Validate mutations (git snapshot before/after for rollback)
5. **Reload** — Agent reinitializes from evolved filesystem state
### Three Pluggable Interfaces
```python
# 1. Agent — implements solve()
class MyAgent(ae.BaseAgent):
def solve(self, task: ae.Task) -> ae.Trajectory:
# Domain-specific solving logic
return ae.Trajectory(task_id=task.id, output=result, steps=steps)
# 2. Benchmark — implements get_tasks() and evaluate()
class MyBenchmark(ae.BenchmarkAdapter):
def get_tasks(self, split="train", limit=None) -> list[ae.Task]:
return [ae.Task(id="1", input="...")]
def evaluate(self, task: ae.Task, trajectory: ae.Trajectory) -> ae.Feedback:
return ae.Feedback(success=True, score=0.95, detail="Passed")
# 3. Engine — implements step()
class MyEngine(ae.EvolutionEngine):
def step(self, workspace, observations, history, trial):
# Mutate workspace based on observations
return ae.StepResult(mutated=True, summary="Updated prompts")
```
## Workflow 1: Evolve an Existing Agent
**Use when**: You have a working agent and want to optimize it against a benchmark.
**Critical Requirements:**
- [ ] Agent implements `BaseAgent.solve()` returning `Trajectory`
- [ ] Benchmark implements `BenchmarkAdapter` with `get_tasks()` and `evaluate()`
- [ ] Seed workspace has `manifest.yaml` with entrypoint and evolvable layers
- [ ] System prompt exists at `prompts/system.md`
- [ ] Workspace is a git repo (run `git init && git add -A && git commit -m "init"`)
### Steps
```python
import agent_evolve as ae
# Configure evolution parameters
config = ae.EvolveConfig(
batch_size=10, # Tasks per solve round
max_cycles=20, # Maximum evolution iterations
evolve_prompts=True, # Mutate system prompt
evolve_skills=True, # Discover and refine skills
evolve_memory=True, # Build episodic memory
evolver_model="us.anthropic.claude-opus-4-6-v1",
)
# Point to your agent workspace and benchmark
evolver = ae.Evolver(
agent="./my-agent-workspace",
benchmark="swe-verified", # Or custom BenchmarkAdapter instance
config=config,
)
# Run evolution
results = evolver.run(cycles=10)
# Inspect results
print(f"Cycles completed: {results.cycles_completed}")
print(f"Final score: {results.final_score}")
print(f"Converged: {results.converged}")
for cycle_num, score in enumerate(results.score_history):
print(f" Cycle {cycle_num + 1}: {score:.3f}")
```
### Post-Evolution
The workspace is now optimized. Inspect what changed:
```bash
cd my-agent-workspace
git log --oneline # See evo-1, evo-2, ... tags
git diff evo-1 evo-10 # Compare first and last evolution
cat prompts/system.md # Read evolved prompt
ls skills/ # See discovered skills
```
## Workflow 2: Add a Custom Benchmark
**Use when**: You want to evolve agents on your own domain-specific tasks.
**Critical Requirements:**
- [ ] Define task format (inputs, expected outputs)
- [ ] Implement scoring logic (0.0–1.0 scale)
- [ ] Prepare task dataset (train + holdout split)
### Steps
```python
import agent_evolve as ae
class CodeReviewBenchmark(ae.BenchmarkAdapter):
"""Evaluate agents on code review quality."""
def get_tasks(self, split="train", limit=None):
tasks = load_review_dataset(split)
if limit:
tasks = tasks[:limit]
return [
ae.Task(id=t["id"], input=t["diff"], metadata={"expected": t["comments"]})
for t in tasks
]
def evaluate(self, task, trajectory):
expected = task.metadata["expected"]
actual = trajectory.output
precision, recall = compute_review_metrics(expected, actual)
f1 = 2 * precision * recall / (precision + recall + 1e-9)
return ae.Feedback(
success=f1 > 0.7,
score=f1,
detail=f"P={precision:.2f} R={recall:.2f} F1={f1:.2f}",
)
# Use with any agent
evolver = ae.Evolver(agent="./my-agent", benchmark=CodeReviewBenchmark())
results = evolver.run(cycles=5)
```
## Workflow 3: Create a Custom Evolution Engine
**Use when**: The default LLM-driven mutation doesn't suit your domain.
### Steps
```python
import agent_evolve as ae
class RuleBasedEngine(ae.EvolutionEngine):
def step(self, workspace, observations, history, trial):
failures = [o for o in observations if not o.feedback.success]
if not failures:
return ae.StepResult(mutated=False, summary="No failures to address")
# Analyze failure patterns
error_types = categorize_errors(failures)
prompt = workspace.read_prompt()
# Append learned rules to prompt
new_rules = generate_rules(error_types)
workspace.write_prompt(prompt + "\n" + new_rules)
return ae.StepResult(
mutated=True,
summary=f"Added {len(new_rules)} rules from {len(failures)} failures",
)
evolveRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.