> Agent-ready spec from Diff of the Day (2026-11-27, idea 4). Give this file to your coding agent (Claude Code, Codex, Cursor) and ask it to build the P0 requirements first.

# Spec: Train a tiny multi-agent team with TRL

## Problem Statement
Most multi-agent setups chain untrained models and retry until something works, which burns tokens. Hugging Face showed that training one shared 0.6B policy for a four-agent task lifted success from about 7% to 82% and beat eight retries of an untrained team at about an eighth of the tokens. Reproducing it on a toy task of your own is the fastest way to learn whether team training is worth it.

## Goals
- Reproduce the walkthrough's result on its own task within 10% of the reported success rate.
- Train the same setup on one toy task of your choice and compare it with best-of-N retries.
- Write up success rate and tokens per solved task for both approaches.

## Non-Goals
- New training algorithms: use the walkthrough's async GRPO setup as is.
- Large models: stay at about 0.6B so one rented GPU is enough.
- A production agent system: this is an experiment.

## User Stories
- As an engineer curious about agent teams, I want to reproduce the published result so that I trust the setup before changing it.
- As an engineer, I want to plug in my own toy task so that I learn whether team training helps outside the paper's example.
- As an engineer, I want cost and success in one table so that I can decide whether to go further.
- Edge case: as an engineer, I want training to save checkpoints so that a lost GPU session does not lose the run.

## Requirements
### P0 (must have)
1. **Reproduction** of the walkthrough's task with its published commands on one rented GPU.
   - [ ] Success rate logged at each evaluation step to a CSV.
   - [ ] Checkpoints saved at least every 30 minutes.
2. **Your toy task**: a small task with an automatic pass/fail check, for example a planner and a coder solving tiny code katas whose tests decide success.
   - [ ] Given a solved kata, when its tests pass, then the episode counts as a success.
3. **Baseline**: the untrained team with best-of-N retries (N = 8) on the same task set.
4. **Results table** `results.md`: success rate and mean tokens per solved task for trained team and baseline.

### P1 (nice to have)
- Charts of success rate over training steps.
- A short write-up post with the results table.

### P2 (future)
- Try two agents instead of four and see how the gain changes.

## Success Metrics
- Leading: reproduction run finishes; success within 10% of the published figure.
- Lagging: on your toy task, the trained team beats best-of-8 on tokens per solved task.

## Open Questions
- Which GPU provider and budget? (you)
- Which toy task has a reliable automatic check? (you)

## Timeline
A weekend: day one for reproduction, day two for your task, baseline and table.

## Agent Instructions
- **Suggested stack**: Python 3.12, TRL and the exact versions named in the walkthrough, one rented H100 or H200.
- **Build order**: environment setup pinned to the walkthrough's versions → reproduction → toy task with its checker and unit tests → baseline → results table → P1.
- **Safety**: put a spending cap on the GPU account; shut instances down when idle; keep API keys in environment variables.
- **Done when**: results.md has both rows filled from real runs.

## Sources
- Training agent swarms with TRL: https://huggingface.co/blog/training-swarms
