|
| 1 | +# @supermemory/eval |
| 2 | + |
| 3 | +SWE-bench Lite retrieval-only evaluation harness comparing two Claude Agent SDK variants: |
| 4 | + |
| 5 | +- **Agent1 (ops-only)**: Read/Grep/Glob tools only |
| 6 | +- **Agent2 (ops+search)**: Read/Grep/Glob + semantic search via `code-chunk` embeddings |
| 7 | + |
| 8 | +## Setup |
| 9 | + |
| 10 | +```bash |
| 11 | +# From monorepo root |
| 12 | +bun install |
| 13 | +``` |
| 14 | + |
| 15 | +Required environment variables: |
| 16 | + |
| 17 | +```bash |
| 18 | +ANTHROPIC_API_KEY=... # Claude API access |
| 19 | +GOOGLE_API_KEY=... # Gemini embeddings (default) |
| 20 | +# or |
| 21 | +OPENAI_API_KEY=... # If using --embedding-provider openai |
| 22 | +``` |
| 23 | + |
| 24 | +## Usage |
| 25 | + |
| 26 | +```bash |
| 27 | +cd packages/eval |
| 28 | + |
| 29 | +# Full evaluation on test split |
| 30 | +bun run src/run.ts |
| 31 | + |
| 32 | +# Dev split, limited instances |
| 33 | +bun run src/run.ts --split dev --max-instances 10 |
| 34 | + |
| 35 | +# Only Agent1 (ops-only) |
| 36 | +bun run src/run.ts --skip-agent2 |
| 37 | + |
| 38 | +# Specific instance |
| 39 | +bun run src/run.ts --instance django__django-12345 |
| 40 | + |
| 41 | +# Custom embedding dimensions (768/1536/3072) |
| 42 | +bun run src/run.ts --embedding-dimensions 768 |
| 43 | +``` |
| 44 | + |
| 45 | +## Options |
| 46 | + |
| 47 | +| Flag | Description | Default | |
| 48 | +|------|-------------|---------| |
| 49 | +| `--split <dev\|test>` | Dataset split | `test` | |
| 50 | +| `--max-instances <n>` | Limit instances | all | |
| 51 | +| `--max-turns <n>` | Max agent turns | 20 | |
| 52 | +| `--max-tool-calls <n>` | Max tool calls | 50 | |
| 53 | +| `--model <name>` | Claude model | `claude-sonnet-4-5` | |
| 54 | +| `--skip-agent1` | Skip ops-only agent | false | |
| 55 | +| `--skip-agent2` | Skip ops+search agent | false | |
| 56 | +| `--instance <id>` | Run specific instance(s) | - | |
| 57 | +| `--run-dir <path>` | Output directory | `./runs` | |
| 58 | +| `--embedding-provider` | `gemini` or `openai` | `gemini` | |
| 59 | +| `--embedding-dimensions` | Gemini output dims | 1536 | |
| 60 | + |
| 61 | +## Output |
| 62 | + |
| 63 | +Runs output to `runs/<timestamp>/`: |
| 64 | + |
| 65 | +``` |
| 66 | +runs/ |
| 67 | +└── 2025-01-01T12-00-00-000Z/ |
| 68 | + ├── events/ |
| 69 | + │ ├── django__django-12345_ops-only.jsonl |
| 70 | + │ └── django__django-12345_ops+search.jsonl |
| 71 | + ├── metrics.jsonl |
| 72 | + └── summary.json |
| 73 | +``` |
| 74 | + |
| 75 | +## Metrics |
| 76 | + |
| 77 | +- **Hit@k**: Whether oracle file appears in top-k predictions |
| 78 | +- **MRR**: Mean Reciprocal Rank of first oracle file |
| 79 | +- **Coverage@k**: Fraction of oracle files in top-k |
| 80 | +- **Time-to-first-hit**: Turns/tool calls until first oracle file accessed |
| 81 | +- **Embedding latency**: Index build + query times (Agent2 only) |
| 82 | + |
| 83 | +## Architecture |
| 84 | + |
| 85 | +``` |
| 86 | +src/ |
| 87 | +├── run.ts # CLI entrypoint |
| 88 | +└── swebench/ |
| 89 | + ├── types.ts # SWEbenchInstance, metrics types |
| 90 | + ├── dataset.ts # HuggingFace dataset loader with caching |
| 91 | + ├── git.ts # Bare clone + worktree management |
| 92 | + ├── score.ts # Per-instance metric computation |
| 93 | + ├── aggregate.ts # Cross-instance aggregation |
| 94 | + ├── run.ts # Main evaluation loop |
| 95 | + ├── agent/ |
| 96 | + │ ├── prompts.ts # Retrieval-only system/user prompts |
| 97 | + │ ├── variants.ts # Agent1/Agent2 tool configurations |
| 98 | + │ └── semantic_search_adapter.ts # Gemini embeddings + MCP server |
| 99 | + └── observe/ |
| 100 | + └── instrumentation.ts # SDK hooks, event writer |
| 101 | +``` |
| 102 | + |
| 103 | +## How it works |
| 104 | + |
| 105 | +1. Loads SWE-bench Lite dataset (300 instances) |
| 106 | +2. For each instance: |
| 107 | + - Creates git worktree at target commit |
| 108 | + - Runs Agent1 (ops-only) with Read/Grep/Glob |
| 109 | + - Builds semantic index using `code-chunk` |
| 110 | + - Runs Agent2 (ops+search) with additional semantic_search tool |
| 111 | + - Computes retrieval metrics against oracle files from patch |
| 112 | +3. Aggregates metrics, prints summary, writes results |
| 113 | + |
| 114 | +## Embedding cache |
| 115 | + |
| 116 | +Semantic search indexes are cached at `~/.cache/swebench-eval/embeddings/` to avoid re-embedding repos. Cache key includes instance ID + embedding provider + dimensions. |
0 commit comments