{"id":"a-evolve","name":"evolving-ai-agents","summary":"LLM駆動の進化アルゴリズムを用いて、あらゆる領域でAIエージェントを自動的に進化・最適化するためのガイダンスを提供します。","body":"# Evolving AI Agents with A-Evolve\n\n## Overview\n\nA-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.\n\n**Benchmark results** (Claude Opus 4.6):\n- MCP-Atlas: 79.4% (#1)\n- SWE-bench Verified: 76.8% (~#5)\n- Terminal-Bench 2.0: 76.5% (~#7)\n- SkillsBench: 34.9% (#2)\n\n## When to Use A-Evolve\n\n**Use A-Evolve when:**\n- Optimizing agent prompts, skills, or memory against a measurable benchmark\n- Building self-improving agents with automated gating and rollback\n- Evolving domain-specific tool usage and procedures through LLM-driven mutation\n- Running iterative solve-observe-evolve loops to maximize agent performance\n- Needing reproducible, git-versioned evolution history for every change\n\n**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.\n\n**Do NOT use A-Evolve for:**\n- Building multi-agent orchestration from scratch (use CrewAI, LangGraph)\n- One-shot agent tasks with no iteration needed (use LangChain, LlamaIndex)\n- RAG pipeline optimization (use LlamaIndex, Chroma)\n- Prompt-only optimization without skill/memory evolution (use DSPy)\n\n## Quick Start\n\n### Installation\n\n```bash\npip install a-evolve                    # Core\npip install a-evolve[anthropic]         # With Claude support\npip install a-evolve[all]               # All providers\n```\n\n### Three-Line Evolution\n\n```python\nimport agent_evolve as ae\n\nevolver = ae.Evolver(agent=\"swe\", benchmark=\"swe-verified\")\nresults = evolver.run(cycles=10)\nprint(f\"Final score: {results.final_score}\")\n```\n\nThis copies the built-in SWE seed workspace, runs 10 evolution cycles against SWE-bench Verified, and returns the optimized agent.\n\n## Core Concepts\n\n### The Agent Workspace\n\nAll evolvable state lives as files in a workspace directory:\n\n```\nmy-agent/\n├── manifest.yaml          # Metadata + entrypoint\n├── prompts/\n│   ├── system.md          # Main system prompt (evolved)\n│   └── fragments/         # Modular prompt pieces\n├── skills/\n│   └── skill-name/\n│       └── SKILL.md       # Reusable procedure with frontmatter\n├── memory/\n│   ├── episodic.jsonl     # Lessons from failures\n│   └── semantic.jsonl     # General knowledge\n├── tools/\n│   ├── registry.yaml      # Tool manifest\n│   └── tool_name.py       # Tool implementations\n└── evolution/             # Managed by engine (metrics, history)\n```\n\n### The Evolution Loop\n\nEach cycle follows five phases:\n\n1. **Solve** — Agent processes a batch of tasks from the benchmark\n2. **Observe** — Benchmark evaluates trajectories, producing (task, trajectory, feedback) triples\n3. **Evolve** — Evolution engine mutates workspace files based on observations\n4. **Gate** — Validate mutations (git snapshot before/after for rollback)\n5. **Reload** — Agent reinitializes from evolved filesystem state\n\n### Three Pluggable Interfaces\n\n```python\n# 1. Agent — implements solve()\nclass MyAgent(ae.BaseAgent):\n    def solve(self, task: ae.Task) -> ae.Trajectory:\n        # Domain-specific solving logic\n        return ae.Trajectory(task_id=task.id, output=result, steps=steps)\n\n# 2. Benchmark — implements get_tasks() and evaluate()\nclass MyBenchmark(ae.BenchmarkAdapter):\n    def get_tasks(self, split=\"train\", limit=None) -> list[ae.Task]:\n        return [ae.Task(id=\"1\", input=\"...\")]\n\n    def evaluate(self, task: ae.Task, trajectory: ae.Trajectory) -> ae.Feedback:\n        return ae.Feedback(success=True, score=0.95, detail=\"Passed\")\n\n# 3. Engine — implements step()\nclass MyEngine(ae.EvolutionEngine):\n    def step(self, workspace, observations, history, trial):\n        # Mutate workspace based on observations\n        return ae.StepResult(mutated=True, summary=\"Updated prompts\")\n```\n\n## Workflow 1: Evolve an Existing Agent\n\n**Use when**: You have a working agent and want to optimize it against a benchmark.\n\n**Critical Requirements:**\n- [ ] Agent implements `BaseAgent.solve()` returning `Trajectory`\n- [ ] Benchmark implements `BenchmarkAdapter` with `get_tasks()` and `evaluate()`\n- [ ] Seed workspace has `manifest.yaml` with entrypoint and evolvable layers\n- [ ] System prompt exists at `prompts/system.md`\n- [ ] Workspace is a git repo (run `git init && git add -A && git commit -m \"init\"`)\n\n### Steps\n\n```python\nimport agent_evolve as ae\n\n# Configure evolution parameters\nconfig = ae.EvolveConfig(\n    batch_size=10,           # Tasks per solve round\n    max_cycles=20,           # Maximum evolution iterations\n    evolve_prompts=True,     # Mutate system prompt\n    evolve_skills=True,      # Discover and refine skills\n    evolve_memory=True,      # Build episodic memory\n    evolver_model=\"us.anthropic.claude-opus-4-6-v1\",\n)\n\n# Point to your agent workspace and benchmark\nevolver = ae.Evolver(\n    agent=\"./my-agent-workspace\",\n    benchmark=\"swe-verified\",     # Or custom BenchmarkAdapter instance\n    config=config,\n)\n\n# Run evolution\nresults = evolver.run(cycles=10)\n\n# Inspect results\nprint(f\"Cycles completed: {results.cycles_completed}\")\nprint(f\"Final score: {results.final_score}\")\nprint(f\"Converged: {results.converged}\")\nfor cycle_num, score in enumerate(results.score_history):\n    print(f\"  Cycle {cycle_num + 1}: {score:.3f}\")\n```\n\n### Post-Evolution\n\nThe workspace is now optimized. Inspect what changed:\n\n```bash\ncd my-agent-workspace\ngit log --oneline              # See evo-1, evo-2, ... tags\ngit diff evo-1 evo-10          # Compare first and last evolution\ncat prompts/system.md          # Read evolved prompt\nls skills/                     # See discovered skills\n```\n\n## Workflow 2: Add a Custom Benchmark\n\n**Use when**: You want to evolve agents on your own domain-specific tasks.\n\n**Critical Requirements:**\n- [ ] Define task format (inputs, expected outputs)\n- [ ] Implement scoring logic (0.0–1.0 scale)\n- [ ] Prepare task dataset (train + holdout split)\n\n### Steps\n\n```python\nimport agent_evolve as ae\n\nclass CodeReviewBenchmark(ae.BenchmarkAdapter):\n    \"\"\"Evaluate agents on code review quality.\"\"\"\n\n    def get_tasks(self, split=\"train\", limit=None):\n        tasks = load_review_dataset(split)\n        if limit:\n            tasks = tasks[:limit]\n        return [\n            ae.Task(id=t[\"id\"], input=t[\"diff\"], metadata={\"expected\": t[\"comments\"]})\n            for t in tasks\n        ]\n\n    def evaluate(self, task, trajectory):\n        expected = task.metadata[\"expected\"]\n        actual = trajectory.output\n        precision, recall = compute_review_metrics(expected, actual)\n        f1 = 2 * precision * recall / (precision + recall + 1e-9)\n        return ae.Feedback(\n            success=f1 > 0.7,\n            score=f1,\n            detail=f\"P={precision:.2f} R={recall:.2f} F1={f1:.2f}\",\n        )\n\n# Use with any agent\nevolver = ae.Evolver(agent=\"./my-agent\", benchmark=CodeReviewBenchmark())\nresults = evolver.run(cycles=5)\n```\n\n## Workflow 3: Create a Custom Evolution Engine\n\n**Use when**: The default LLM-driven mutation doesn't suit your domain.\n\n### Steps\n\n```python\nimport agent_evolve as ae\n\nclass RuleBasedEngine(ae.EvolutionEngine):\n    def step(self, workspace, observations, history, trial):\n        failures = [o for o in observations if not o.feedback.success]\n        if not failures:\n            return ae.StepResult(mutated=False, summary=\"No failures to address\")\n\n        # Analyze failure patterns\n        error_types = categorize_errors(failures)\n        prompt = workspace.read_prompt()\n\n        # Append learned rules to prompt\n        new_rules = generate_rules(error_types)\n        workspace.write_prompt(prompt + \"\\n\" + new_rules)\n\n        return ae.StepResult(\n            mutated=True,\n            summary=f\"Added {len(new_rules)} rules from {len(failures)} failures\",\n        )\n\nevolver = ae.Evolver(\n    agent=\"./my-agent\",\n    benchmark=\"my-benchmark\",\n    engine=RuleBasedEngine(),\n)\n```\n\n## Built-in Components\n\n### Seed Agents\n\n| Agent | Domain | Model | Key Feature |\n|-------|--------|-------|-------------|\n| `swe` | SWE-bench | Claude Opus 4.6 | Verify-fix loop, skill proposals |\n| `terminal` | Terminal-Bench | Claude Sonnet 4 | Concurrent timeout, env discovery |\n| `mcp` | MCP-Atlas | Claude Opus 4.6 | MCP server integration |\n\n### Benchmarks\n\n| Name | Domain | Metric |\n|------|--------|--------|\n| `swe-verified` | Code patching | Pass rate |\n| `mcp-atlas` | Tool calling | Accuracy |\n| `terminal2` | Shell tasks | Pass rate |\n| `skill-bench` | Multi-step procedures | Accuracy |\n| `arc-agi-3` | Interactive games | RHAE score |\n\n### Evolution Algorithms\n\n| Algorithm | Strategy | Best For |\n|-----------|----------|----------|\n| A-Evolve/SkillForge | LLM-driven workspace mutation | General-purpose |\n| Guided Synthesis | Memory-first, curated skills | Skill discovery |\n| Adaptive Evolution | Reward tracking, filtered observations | Fine-grained control |\n| Adaptive Skill | Skill-centric refinement | Skill-heavy domains |\n\n## Configuration Reference\n\n```python\nae.EvolveConfig(\n    batch_size=10,              # Tasks per solve round\n    max_cycles=20,              # Max evolution iterations\n    holdout_ratio=0.2,          # Test set split for gating\n    evolve_prompts=True,        # Mutate system prompts\n    evolve_skills=True,         # Discover/refine skills\n    evolve_memory=True,         # Build episodic memory\n    evolve_tools=False,         # Mutate tool implementations\n    trajectory_only=False,      # Hide scores from evolver\n    evolver_model=\"us.anthropic.claude-opus-4-6-v1\",\n    evolver_max_tokens=16384,\n    egl_threshold=0.05,         # Convergence epsilon\n    egl_window=3,               # Cycles for plateau detection\n)\n```\n\n**Convergence**: Evolution stops early when score improvement is less than `egl_threshold` over the last `egl_window` cycles.\n\n## Skill Format\n\nSkills are reusable procedures discovered and refined during evolution:\n\n```markdown\n---\nname: verify-edge-cases\ndescription: \"TRIGGER when: checking boundary conditions. DO NOT TRIGGER: for happy-path tests.\"\n---\n\n## Pattern\nTest all falsy-but-valid values: 0, False, \"\", [], {}\n\n## Process\n1. List all input boundaries\n2. Run each against the implementation\n3. Check both output AND side effects\n```\n\nSkills accumulate in the workspace `skills/` directory. The evolver curates them: ACCEPT new skills, MERGE overlapping ones, SKIP redundant proposals. Target: 5–10 broad skills, not 30 narrow ones.\n\n## Common Issues\n\n### Evolution score plateaus early\n\n**Cause**: Batch size too small or evolver doesn't see enough failure diversity.\n**Fix**: Increase `batch_size` (try 15–20) and ensure benchmark tasks cover diverse failure modes. Set `trajectory_only=False` so the evolver sees scores.\n\n### Agent workspace grows too large\n\n**Cause**: Skill library bloat from accepting every proposal.\n**Fix**: The default SkillForge engine curates skills automatically. If using a custom engine, implement merging logic to consolidate overlapping skills.\n\n### Git conflicts during evolution\n\n**Cause**: Multiple evolution runs on the same workspace.\n**Fix**: Each `evolver.run()` should operate on its own workspace copy. Use `Evolver(agent=\"seed-name\")` to auto-copy the seed each time.\n\n### LLM provider errors during evolution\n\n**Cause**: Rate limits or authentication issues with the evolver model.\n**Fix**: Check `evolver_model` config. For Bedrock, ensure AWS credentials are configured. For Anthropic, set `ANTHROPIC_API_KEY`.\n\n### Custom agent not picking up evolved state\n\n**Cause**: Agent doesn't implement `reload_from_fs()`.\n**Fix**: Override `reload_from_fs()` in your `BaseAgent` subclass to re-read prompts, skills, and memory from the workspace after each evolution cycle.\n\n## Usage Instructions for Agents\n\nWhen this skill is loaded:\n\n1. **Read this entire file** before implementing any evolution workflow\n2. **Start with the Quick Start** — get a minimal evolution running before customizing\n3. **Use built-in seeds when possible** — `\"swe\"`, `\"terminal\"`, `\"mcp\"` have battle-tested configurations\n4. **Always initialize git** in custom workspaces before running evolution\n5. **Check convergence settings** — default `egl_threshold=0.05` with `egl_window=3` may be too aggressive for your domain\n6. **Inspect evolved state** after each run — read `prompts/system.md` and `skills/` to understand what the evolver learned\n\n**Pro Tips:**\n- Set `trajectory_only=False` (default) so the evolver sees scores — this accelerates learning\n- Start with `batch_size=10` and adjust based on task diversity\n- Use `holdout_ratio=0.2` to prevent overfitting to training tasks\n- After evolution, `git diff evo-1 evo-N` shows the cumulative effect of all mutations\n- If the evolver isn't finding skills, enrich `feedback.detail` strings with specific failure reasons\n\n**Warning Signs:**\n- Score oscillating between cycles → benchmark evaluation may be non-deterministic\n- Skills directory growing past 15+ skills → engine isn't merging/curating properly\n- Prompt growing past 10K chars → evolution is appending without refactoring\n- `converged=True` after 2-3 cycles → increase `egl_window` and decrease `egl_threshold`\n\n## References\n\n- **Architecture deep dive**: See [references/architecture.md](references/architecture.md)\n- **API reference**: See [references/api.md](references/api.md)\n- **Step-by-step tutorials**: See [references/tutorials.md](references/tutorials.md)\n- **Real-world examples**: See [references/examples.md](references/examples.md)\n- **GitHub issues & solutions**: See [references/issues.md](references/issues.md)\n- **Design patterns**: See [references/design-patterns.md](references/design-patterns.md)\n- **Release history**: See [references/releases.md](references/releases.md)","author":"@Orchestra-Research","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/Orchestra-Research/AI-Research-SKILLs/tree/main/14-agents/a-evolve","license":"MIT","category":"devops","lang":"en","tokens":3309,"stars":0,"calls30d":2,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[{"path":"references/api.md","size":15810,"sha256":"02a94cd9cfd66a9783cfaedd9adb514aa5b918dbca459527cfbbdb5dd72f12d8"},{"path":"references/architecture.md","size":15505,"sha256":"909cee4ffc48d96d6bc004ad02511ab8e2f4b0b243b59b6fe90e9aa6c1170b93"},{"path":"references/design-patterns.md","size":15192,"sha256":"57c245cacf1813b141e6b8b8abfe4304dfcd0b90ddd43a941effa4a695138f91"},{"path":"references/examples.md","size":10015,"sha256":"7cdb3374d2988f96a722a1c9762431da18806f8fc89f7f15eecd51c847aa1432"},{"path":"references/issues.md","size":16411,"sha256":"befe46cde9ae3bcbddfde9941f9a8e1ee982d3e8443c0c435d8ec749e7119e2e"},{"path":"references/README.md","size":27098,"sha256":"a6a94d1f5e67b2deb0b3f7473d521277617420216bd25cbd13b80df8c08c823b"},{"path":"references/releases.md","size":4561,"sha256":"b2b0cabccfde9277a1ce2090e1201047f04b566a1f53348fc185fbec36a762b3"},{"path":"references/tutorials.md","size":23161,"sha256":"2460529aa5649ab770fe1e5826b79a9a3b9dd0451ceb085531441eb5d2f58dbc"}],"requires":{"mcp":[],"tools":[]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":false,"networkEndpoints":[]}}