# Ouroboros > Ouroboros keeps a coding agent (Claude Code, Codex or Pi) working on a repo for hours without supervision, and makes the long run hold together. A human writes a charter: the goal, what "done" means, the constraints. Then a loop runs, each turn in a fresh context: a worker does one unit of work and commits it; a writer checks that turn against the charter, records what happened in a memory graph, and names the claim the next turn works on. The run never blocks on a question, never takes "done" on trust, and leaves a branch you can read, a live page of findings tied to the memory behind them, and a report on what to merge. Open source (MIT), Python 3.12+. This file is the plain-text version of https://borris.dev for agents and LLMs: what Ouroboros is, where it stands, and how to get a run going. The source, README and design are on GitHub. ## Status (1 November 2026) - Version 0.1.0, installed from source; not on PyPI. - The default loop is **worker-writer** (two roles, both fresh every turn), since 1 November 2026. It has passed short end-to-end runs on Claude Code (Opus 5.5) and on Codex. The long overnight runs so far used the older **standard** loop (actor, critic, scribe), which still ships as `loop: standard`. - Memory: **Governor**, a graph in a local Flywheel repository, is the standard store when it is installed; otherwise the same model lives as markdown files in git. Nothing extra is needed to start. - Not built yet: several workers in parallel, several runs sharing one graph, changing a live run's config (the charter can change; it is re-read every turn). See Roadmap. - The run shown on borris.dev (a 2048 bot, 32 hours, 127 iterations) is a made-up demo in the shape of a real run; its dial replays real stage times. A real run is coming to the site. ## The idea in six lines 1. **The charter speaks for the human.** `.ouroboros/goal.md`: mission, done criteria written as claims about the world, constraints, a question policy, a quality bar. No agent can edit it. 2. **Fresh context every turn.** Long runs fail when one context fills with its own history. Each turn starts clean, and the memory does the remembering. 3. **Memory is a graph of claims and records.** Records say what each turn did; claims say what is true now and what is open, as a tree under the done criteria. The next step is always one of the tree's open leaves. 4. **Every turn is judged.** The writer grades the work against the charter, refuses a "done" the evidence does not support, and records a failed turn too, so it is fixed forward rather than repeated. 5. **It never stops early and never blocks.** Questions are answered from the question policy; a usage limit switches to a fallback harness; only a stop condition the user set ends the run. 6. **Motion is not progress.** Two mechanical counters catch a run that is busy but ships nothing, and change its course. ## Quick start For an agent setting this up for a user. Steps 1-3 happen once per machine; steps 4-8 once per repo and run. 1. **Check the prerequisites.** `python3 --version` (3.12+), `uv --version`, `git --version`, and at least one logged-in agent CLI: `claude`, `codex` or `pi`. To outlive the terminal, a run uses tmux (picked automatically when installed), tern, or a systemd user session; with none of them it runs in the foreground. 2. **Install Ouroboros.** ```bash git clone https://github.com/theo-kirby/ouroboros.git && cd ouroboros uv tool install --editable . ouroboros skills install --user # ouroboros-design, -launch and -checkup, for claude, codex and pi ``` 3. **Optional: Governor memory.** Skip it and the run keeps its memory as files. ```bash npm install -g @paradigma-inc/flywheel # Node 24+ git clone https://github.com/theo-kirby/governor.git && cd governor npm ci && npm run build && npm link # puts governor on PATH ``` 4. **In the repo to work on, start from a clean working tree** (commit or stash first; `--allow-dirty` overrides), then run `ouroboros init`. It writes `.ouroboros/config.yml` (every setting at its default), a charter template at `.ouroboros/goal.md`, and an operating guide for agents at `.ouroboros/AGENTS.md`; it points the repo's `AGENTS.md` or `CLAUDE.md` at that guide and gitignores the run directory. Agents opened in the repo later read the guide: what the last runs did and which command does what. 5. **Write the charter.** `ouroboros design` interviews the user in their agent CLI. As an agent you can instead use the `ouroboros-design` skill in your own session, or fill in `.ouroboros/goal.md` with the user (format below). The charter belongs to the user: confirm its mission, done criteria and constraints with them. 6. **Check, then start, always with a stop condition.** The default config has no time limit, so a run with no stop rule goes on until it is stopped. ```bash ouroboros preflight # everything `run` checks, without starting ouroboros run --for 8h # on branch ouroboros/; --max-usage 0.8 also caps the weekly window ``` 7. **Watch it.** `ouroboros top` (live terminal view) or `ouroboros view` (the run's live page; `--host 0.0.0.0` for a phone). `ouroboros watch`, started by `run`, pushes alerts and a digest every 4 hours to Pushover when `PO_USER` and `PO_TOKEN` are set. 8. **Read and merge.** `ouroboros report` writes REPORT.md. Read it and the branch, then merge with a merge commit, not a squash: records cite commit SHAs. The `ouroboros-checkup` skill gives a merge recommendation or a mid-run correction. Running the same run name again continues that run; `ouroboros stop` ends one early. The `ouroboros-launch` skill does steps 4-7 with the user: it reads past runs, revises the charter, runs the preflight, picks the run name and stop rules, and launches. ## Commands | Command | What it does | |---|---| | `ouroboros init [--name NAME]` | Writes the config, the charter template and the agents' operating guide | | `ouroboros design` | Writes the charter by interview, in claude, codex or pi | | `ouroboros preflight` | Checks everything `run` checks, without starting | | `ouroboros run --for 8h` | Starts the loop where `launcher:` says (tmux, tern, systemd or here). Also `--max-iterations N`, `--max-usage 0.8`, `--harness`, `--model`, `--memory auto|governor|files`, `--foreground` | | `ouroboros top` / `status` | The live terminal view / the current state | | `ouroboros view` | Serves the run's live page | | `ouroboros stop` | Stops the running loop | | `ouroboros report` | Writes REPORT.md | | `ouroboros refresh` | Rechecks logins and usage, and wakes a waiting run | | `ouroboros watch` | Phone alerts and digests (started by `run`) | | `ouroboros archive` | Writes the durable record into git (`run` and `stop` do it too) | | `ouroboros mem brief | tree | orient | show | record | fold | check | render` | The run's memory, the same verbs on either store | | `ouroboros plot fig.py` / `shot URL name` | Figures in the house palette / headless screenshots, whatever the project's language | | `ouroboros skills install --user` | Installs the user skills | `ouroboros` with no arguments opens a menu. ## The charter `.ouroboros/goal.md`, owned by the human: ```markdown # Goal: ## Mission one paragraph: what and why, priorities in order ## Done criteria - [ ] claims about the world, not tasks ## Horizon ladder short-term, medium-term, long-term ## Constraints never do X; always keep Y green ## Question policy how to decide for me: "prefer the reversible option" ## Exhaustion policy creative | maintain | report_done ## Quality bar what the writer grades against ``` "Done" is a verdict, not a stop: when the criteria are met, the run climbs the horizon ladder until a stop condition ends it. ## The loop Default, `loop: worker-writer`. Turn 0: the writer seeds the memory from the charter (each done criterion as an open gap) and names the first target claim. Then every iteration: worker, commit, writer, commit. | Role | Each iteration | `ouroboros mem` verbs | |---|---|---| | Worker | Gets the target claim whole (its place in the tree, what is ruled out, its records) and, per `handoff: graph | both | prompt`, the memory's brief and/or a written step. Orients, does one unit of work to the end, tests it, commits, and reports in JSON. Never writes the memory. | `brief` `tree` `orient` `show` | | Writer | Reads the report, the diff and the commits. Grades the turn against the charter, refuses an unsupported "done", records the turn (a failed one too), grows the claim tree, folds, keeps "ruled out" apart from "fix and resubmit", checks the next step against the host and the ruled-out knowledge, and names the next target. The only memory writer. Returns strict JSON. | reads, plus `record` `fold` `check` `render` | Verdicts: `continue | answer | done_rejected | done_accepted | stuck | looping | reject`. Nothing is reverted; a rejected turn is recorded and fixed forward. A failing or garbled call never stops the loop. The engine itself, with no model, keeps the stop rules, the no-early-exit rule, loop detection, usage limits and backoff, and the final report. `loop: standard` is the older actor, critic, scribe loop, where the critic reverts a rejected iteration's commits. ## Configuration The main settings in `.ouroboros/config.yml`: ```yaml loop: worker-writer # or `standard`: actor, critic, scribe handoff: graph roles: worker: { harness: claude, model: claude-opus-5-5, timeout: 45m, fallback: [{ harness: codex }] } writer: { harness: claude, model: claude-opus-5-5, timeout: 20m, fallback: [{ harness: codex }] } stop: { after: 8h, max_usage: 0.8 } # not set by default: set one, or pass --for memory: auto ``` Stop conditions: `after`, `max_iterations`, `max_usage` (a fraction of the weekly subscription window), `max_cost_usd` (API-billed harnesses only), `until`, `on_done_accepted`, `max_stuck` (25 by default). `limits.reserve` (e.g. `{claude: 0.85}`) takes one harness out once its weekly window passes that fraction, without stopping the run. `profile: research` or `development` shapes the final report as a paper or a product report. ## Memory Records are append-only; each says what it changes and which records it follows from. State is a tree of claims that cite records: each done criterion's gap at the top, and under it the sub-problems, hypotheses and questions the work opens. Only the writer's fold writes state. Agents reach either store through `ouroboros mem`, each role with its own verbs, and both stores enforce the same rules. - **Governor** (standard): a graph in a local Flywheel repository (`.flywheel/`, outside git; only STATE.md is committed). With `flywheel` and `governor` on PATH, `memory: auto` creates it when a run starts. Every memory write is a Flywheel commit; `flywheel repo:push` and `repo:pull` sync it with a hosted repository. - **Files** (fallback, nothing to install): the same model as markdown under `.ouroboros/graph/`, committed on the run branch, one file per node with a uuid, so a later import into Flywheel never duplicates. A repo whose runs already use files keeps them. ## What a run leaves - **The branch** `ouroboros/`, with the work committed turn by turn. - **The live page**, `.ouroboros/runs//view/index.html`, written for someone who does not know the code: a short summary; the loop as a dial; key figures and gauges for time, usage, tokens and progress toward done; the done criteria and the open problems; then the **findings** the writer keeps (each a title, a short summary, a holds / revised / retracted status, its figures, the part of the memory graph it rests on, and notes); then the **memory graph and timeline** as one picture, where clicking an iteration or a finding brings its nodes forward. When the run stops, the writer writes a paper or product report, and the page opens on it behind a Run / Paper toggle. - **REPORT.md** (`ouroboros report`), and the run directory `.ouroboros/runs//` (gitignored: `status.json`, `iterations.jsonl`, `critic.jsonl`, `loop.log`, `transcripts/`, `view/`, and `NEEDS_HUMAN.md` only while something needs the user). `ouroboros archive` commits the durable record: `.ouroboros/RUNS.md` and `.ouroboros/history/.md`. ## The rules a run keeps 1. Follow the charter. Every turn is graded against it; no agent can edit it. 2. Prove every claim. A claim the diff and the tests do not support is refused, "done" most of all. 3. Report as it goes. Every iteration writes a record; the page and the phone digest stay current. 4. Do work, not motion. One bounded unit per iteration, done to the end. No change, no commit. 5. Never block, never stop early. Only a stop condition the user set ends a run. Two counters watch rule 4, because an agent asked "are you looping?" always finds a reason why this time is different: `no_product` (iterations that changed only memory, fires at 8) and `no_frontier` (iterations that left the open problems unchanged, fires at 30). First the loop is named in the next prompt; then the model changes. One real run did 201 iterations, changed 22,437 lines and wrote 128 records while moving the frontier by one node; that is why they exist. ## Roadmap (open problems) - Several workers on separate worktrees in one run. - Several runs, or a run and a person, sharing one graph (an importer from a files run's branch at merge). - Changing the config, models, stop limits and timer of a live run without a restart. - More architectures as presets: planner and worker trees, harnesses that take turns, custom pipelines. - More memory stores behind the same `ouroboros mem` verbs. - A busy run that ships nothing: watched by the counters, not solved. ## A real run 2048 bot, 17 October 2026, on the standard loop: build a correct 2048 game and a bot, then improve the bot one change at a time, every claim a number from a seeded benchmark. 4 iterations in 29 minutes, every done criterion met, 0 reverts, 1% of the Claude weekly window. 1. Built the engine with 51 rule tests (4 min). 2. Added a seeded bench command, random and greedy baseline bots, and bench.csv (2 min). 3. Added a depth-2 expectimax bot: 2048 in 14 of 20 seeded games; "done" accepted (9 min). 4. Bit-packed boards with 65,536-row move tables: 3x faster; depth 3 gets a median of 40,920 (13 min). The run went on up the horizon ladder. ## Links - [GitHub repository](https://github.com/theo-kirby/ouroboros): source, issues, MIT license - [README](https://raw.githubusercontent.com/theo-kirby/ouroboros/main/README.md): install, run, configuration, memory, phone alerts - [DESIGN.md](https://raw.githubusercontent.com/theo-kirby/ouroboros/main/DESIGN.md): the loops, the roles' JSON contracts, harness drivers, fallbacks, budgets, observability, lessons from real runs - [AGENTS.md](https://raw.githubusercontent.com/theo-kirby/ouroboros/main/AGENTS.md): the contract for changes to the Ouroboros repo itself - [Governor](https://github.com/theo-kirby/governor): the memory graph's conventions, CLI and viewer - [Flywheel](https://docs.flywheel.paradigma.inc): Paradigma's research graph, which Governor stores into - [borris.dev](https://borris.dev): the human-facing page, in the style of a run report