# Overview

> Three swarms to copy and run with one API key, then five larger ones shaped after long-horizon benchmarks.

The `examples` folder in the repository starts with three swarms you can copy and run. Each is one folder: a `main.cvy`, a Markdown prompt per agent, and a README. Each needs one API key, Anthropic or OpenAI, and nothing else.

| Example | Shape | What you get | What it teaches |
|---|---|---|---|
| `writer_critic` | two agents in a loop | a short piece of writing, approved by a critic | topics, `watches` and `writes`, typed `output`, `done_when` |
| `research_team` | parallel researchers, a writer, an editor | a sourced briefing in `report.md` | `for_each`, `inputs` as the dependency graph, tools, a numeric `done_when` |
| `code_team` | a planner, two coders, a reviewer | a tested Python package in `./workspace` | `count`, addressed messages, a `done_when` backed by a passing test suite |

## Running one

Start `convoyd` with a key in its environment ([install](/docs/install/) covers getting it):

```sh
export ANTHROPIC_API_KEY=sk-ant-...   # or: export OPENAI_API_KEY=sk-...
convoyd
```

Then, in another terminal:

```sh
cd examples/writer_critic
convoy run
convoy watch writer_critic    # the swarm's name is the label of its swarm block
```

Run `convoy` from inside the example's folder. `research_team` and `code_team` write their results there.

## Anthropic or OpenAI

Every one of the three declares a single provider, and its block carries both choices:

```hcl
provider "llm" {
  source = "claude_agent_sdk"  # "openai_agents"
  model  = "claude-sonnet-5-5" # "gpt-6.1-sol"
}
```

As written they use an Anthropic key. For an OpenAI key, change those two lines to the values in the comments. The agents inherit the provider's model, and the tools they use (`web_search`, `bash`, `read_file`, `write_file`, `edit_file`) have the same names on both, so nothing else in the file changes.

## Benchmark swarms

`examples/benchmarks` holds five larger swarms and one baseline, one per long-horizon benchmark. Each is a complete `convoy run` target: a `main.cvy` (plus other `.cvy` files where the sample shows merging), a `prompts` folder, and a README that maps the swarm to its benchmark and lists what the folder assumes about the machine. They were chosen so that each shows a different shape of the language.

Every benchmark folder passes [`convoy validate`](/docs/cli/validate/) with zero errors, and zero warnings except one expected `TS051` on the solo arm. Each needs its benchmark's own setup (a checkout, a simulator, a task folder) before a run does anything useful, and none has been run end to end yet.

### The five shapes

| Folder | Benchmark | Shape | `done_when` |
|---|---|---|---|
| `01_paperbench_replication` | PaperBench | fan-out, fan-in, then a judge loop | the judge approves |
| `02_commit0_library` | Commit0 | task board with a worker pool | 95% of the real test suite passes |
| `02_commit0_library/solo` | Commit0 | one agent, same budget | 95% of the real test suite passes |
| `03_vending_bench` | Vending-Bench 2 | self-sustaining daily loop | day 365 or bankrupt |
| `04_swe_lancer_bounty` | SWE-Lancer | competition, pick, implement, test | the end-to-end tests pass |
| `05_tau2_pass_k_loop` | τ²-bench | improvement loop, then a held-out gate | held-out pass^4 gain of 10 points |

### Which features each one leans on

| Feature | Where it appears |
|---|---|
| `for_each` over a map | PaperBench builders, τ²-bench runners |
| `for_each` over `toset()` | Commit0 implementers |
| Typed, nested `output` | every folder |
| `values(agent.x)[*].output` | PaperBench experimenter |
| `depends_on` | PaperBench judge, SWE-Lancer QA |
| `inputs` diamond | SWE-Lancer manager |
| `can_spawn` and `create_agent` | Commit0 implementers; switched off in the solo arm |
| Three SDKs in one swarm | Vending-Bench, SWE-Lancer |
| Multi-file configuration | Vending-Bench |
| `vars` as experiment knobs | τ²-bench |

### Conventions shared by every benchmark folder

- Every `swarm` block declares its `overseer = { provider, model }` and a `max_cost_usd`. The overseer's spend counts toward the cap. There is no `max_agents`; `convoyd --max-processes` limits concurrency.
- `api_key` names an environment variable that `convoyd` reads from its own environment. Keys never travel in the bundle.
- Only agents with `can_spawn = true` may call `create_agent` (Commit0's implementers). The overseer may spawn unless its block sets `can_spawn = false`.
- Agents call `report_progress(summary)` after each meaningful step. The overseer and `convoy status` read it.
- A turn starts with an unread summary of the board. Messages addressed to the agent arrive in full; everything else the agent pulls with `read_topic`.
- The first line of each prompt file is the role summary that `list_agents` shows. The rest becomes the YOUR JOB section of the agent's system prompt.
- `{{name}}` in a prompt is replaced from the agent's `vars`. Everything else in the prompt is literal.
- Paths the agents share (a checkout, a workspace, a runs folder) come in through `env("...")` inside `vars`. `convoy run` reads those variables on the laptop and ships them with the bundle; a missing one fails before anything starts.
- Every agent that watches a topic has an explicit `max_turns`. An agent that watches nothing takes continue turns until it calls `finish` or reaches `max_turns`; most of them finish in their first turn.
- Every topic has at least one declared writer and one declared watcher, so `convoy validate` is clean of the unused-topic warnings.
- Every `human` topic has a watcher, so `convoy say <swarm> human "..." --to <agent>` reaches someone. The exception is the Commit0 solo arm, whose one agent watches nothing and is reached with `--to solo`; it gets the one expected `TS051` warning.
- A provider running a local model declares `price = { input = 0, output = 0 }`, since the built-in price table only knows hosted models and every swarm sets `max_cost_usd`.
- Model names follow the proposal's convention (`claude-opus-5`, `claude-sonnet-5`, `gpt-6.1-sol`, an Ollama tag). Each is set in its agent block.

### Running any of them

```sh
cd examples/benchmarks/<folder>
convoy validate            # offline; checks every rule in the validation reference
convoy run                 # sends the folder to convoyd
convoy watch <swarm name>  # the swarm name is the label of the swarm block
convoy say <swarm name> human "<text>" --to <agent>
```

See [`convoy validate`](/docs/cli/validate/), [`convoy run`](/docs/cli/run/), [`convoy watch`](/docs/cli/watch/) and [`convoy say`](/docs/cli/say/). Each example page lists the environment variables and tools its folder needs.
