Training recipes are usually fixed before the first step. OPAL, short for OPtimizer with an Agent in the Loop, makes the optimizer a program that a coding agent keeps rewriting during the run. It was published on 21 October by Xingjian Bai, Jia-Hao Liang, Jayden Teoh and Vincent Sitzmann, with a write-up, under the MIT license.
How it works
You wrap your existing torch.optim optimizer in one line. Every so often the agent, Claude Code by default, reads what the run reports and may rewrite two small programs: the one that turns gradients into updates, and one that measures whatever the agent wants to look at.
- What it may change: update rules per parameter group, learning rates and schedules, momentum and beta2, preconditioning, clipping and guards against loss spikes.
- What it is told not to touch: your model, data, loss, batch size, number of steps and evaluation. The authors note this is a rule, not a sandbox, because the programs run inside your training process.
- Safety nets: a new program runs on trial for 20 steps and falls back if it errors. Until the agent changes anything, the run is bit-for-bit the same as a plain one.
What the authors report
Each result is a single run:
| Task | Official recipe | With OPAL |
|---|---|---|
| SiT-B/2, ImageNet 256, FID-50K | 35.7 | 23.6 |
| LightningDiT-B/1, FID-50K with guidance | 3.22 | 2.31 |
| Goldfish 125M, Swahili, FLORES-200 bits | 79.37 | 77.25 |
| modded-nanogpt record #36, val loss | 3.2781 | 3.2749 |
The README is upfront that it “does not always help”: one modded-nanogpt run ended worse than the record, and the agent cannot restart or roll back training. On cost, the authors put about 100 agent decisions on a LightningDiT run at $6.42 at Claude Opus 5.5 list price, next to about 74 H100-hours of training. Waiting for the agent made runs 1.30 to 4.39 times slower; not waiting added 1.01 to 1.14 times.
Before you try it
- Install
opal-optimizerfrom PyPI, notopal, which is an unrelated package. - There is no spending cap by default. Set
max_cost_usd. An experimental Codex backend ignores that cap. - Supported: CPU, one GPU, or DDP on one node. Multi-node, FSDP and DeepSpeed are not.
- Run
backend="keep"first: no agent, no cost, and the losses must match your plain run step for step.

The Campfire
No commentsNobody has pulled up a log by this one yet. Be the first to say what you make of it.
Held for the desk. It appears after a look.