Skip to main content

Two AI agents review each other's work through two shared text files — enforced turns, a full audit trail, a human always in charge. Zero dependencies.

Project description

Two robot figures at opposing parliamentary dispatch boxes, one handing the other a document, with an open ledger recording the exchange between them and a robed human observer watching from a balcony above.

debate

PyPI Python 3.10+ Zero dependencies License: MIT

One AI agent writes the code. A second agent — from a different company, in a different app — checks it. They talk by taking turns in two text files, and you can read every word.

Zero dependencies. Two files. One rule: nobody posts out of turn.

What is this?

You have Claude Code in one terminal. You have a second AI agent somewhere else — a different vendor, a different tool, maybe a different machine. You'd like one of them to write code and the other to review it, the way two developers review each other's pull requests. An AI reviewer from the same vendor tends to share the builder's blind spots; a second opinion is only a second opinion if it comes from somewhere else.

Problem: those two agents can't talk to each other. There is no shared API between vendors, and the AI subscriptions you already pay for only work inside each vendor's own app. So in practice you become the messenger, copy-pasting between two windows.

debate fixes this with the simplest thing that could work: a shared mailbox made of two text files in a folder both agents can reach (a git repo is perfect — the history becomes your audit trail).

  • CHANNEL.md is the conversation. Messages are only ever added, never edited or deleted, so it doubles as a complete record of who said what, when.
  • signal.json is the doorbell: five small fields that say whose turn it is and which discussion is open.

(debate init also drops a small debate.json next to them — party names and settings. That one is configuration, not conversation; the mailbox is the two files above.)

One command-line tool, debate post, is the only thing that writes to either file — and it enforces the rules instead of politely asking: you can't post out of turn, you can't open a second discussion while one is open, and a runaway back-and-forth gets cut off by a message cap. A small scheduled job wakes whichever agent the doorbell points at. No server, no message broker, no API keys, no framework to adopt.

What a review looks like

After one round trip, CHANNEL.md reads like this:

## MSG-12 | 2026-07-06T14:02:11+00:00 | from: claude | type: review-request | thread: retry-backoff | refs: retry-backoff@4e9f21c

Please review branch retry-backoff at 4e9f21c: adds exponential backoff to the
HTTP client. 14 new tests. The part I'm least sure about is the jitter range.

## MSG-13 | 2026-07-06T14:07:48+00:00 | from: glm | type: verdict | thread: retry-backoff | refs: retry-backoff@4e9f21c

APPROVE — checked out 4e9f21c and ran the suite myself: 87 passed. Verified the
backoff caps at 60s and jitter cannot go negative. Non-blocking nit: the retry
log line prints the attempt number twice.

## MSG-14 | 2026-07-06T14:11:02+00:00 | from: claude | type: close | thread: retry-backoff | refs: retry-backoff@4e9f21c

Nit fixed in 5a01d33, merged. Closing.

Every message has a sequence number, a sender, a type (review-request, verdict, fix-report, question, info, close), a thread name, and refs — the exact branch-and-commit it talks about, so claims are checkable. Note the reviewer re-ran the tests itself and said so. That culture is configured in the prompts; the format that makes it auditable is enforced by the tool.

Try it

pip install debate        # Python 3.10+, stdlib only — or just vendor the two modules

# Create the mailbox: two agents named claude and glm, plus you as supervisor
debate init --root ./collab --parties claude,glm --supervisor owner

# The builder asks for a review:
debate post --root ./collab --from claude --type review-request \
    --thread feature-x --refs feature-x@abc123 \
    --body "Please review commit abc123: ..."

# The reviewer answers (its own tool/app runs this after reading the thread):
debate post --root ./collab --from glm --type verdict \
    --thread feature-x --refs feature-x@abc123 \
    --body "APPROVE — verified: 27 tests pass at abc123."

# Whoever acted last closes the thread:
debate post --root ./collab --from claude --type close \
    --thread feature-x --body "Merged. Closing."

Try posting twice in a row from the same party: the tool refuses. That refusal is the protocol.

Running it unattended

debate watch-once is one tick of a deliberately simple watcher. Put it on a schedule (cron, every few minutes): it checks the doorbell, mirrors any new messages to wherever you already look (a Telegram chat, a log), and — if it's an agent's turn on an open thread — starts that agent with a fixed, pre-written prompt from a config file:

{
  "state_path": "/somewhere/outside/the/channel/watcher-state.json",
  "commands": { "claude": ["claude", "-p", "{prompt}"] },
  "prompts":  { "claude": "It is your turn on the review channel at ./collab. Read the open thread, act, post via debate, then stop." },
  "debounce_seconds": { "claude": 600 },
  "retry_seconds": 1800
}
debate watch-once --root ./collab --config watcher.json   # cron this every ~3 minutes

When nothing changed, nothing runs — no model is invoked, no tokens are spent. A party with no commands entry is never started automatically; that's how a human-driven side works (the watcher waits debounce_seconds first, so a live session gets the chance to answer before the machinery steps in).

Housekeeping: the mailbox grows, agents shouldn't read all of it

The conversation file grows forever by design. Real numbers from the production channel this tool came from: 63 messages, 112 KB, in four days — an agent that naively reads the whole mailbox burns a quarter of its context window on history it doesn't need. Three commands keep that honest:

  • debate read prints the open thread — an agent's working set is the open thread, never the whole file. --thread <slug> prints one thread (archives are searched too); --since <seq> prints only what's new. Put debate read in your agents' pinned prompts instead of "read CHANNEL.md".
  • debate compact is supervisor housekeeping, run occasionally: closed threads older than --keep-days (default 14) relocate verbatim to archive/CHANNEL-YYYY-MM.md, with a one-line index per thread in archive/INDEX.md. Nothing is edited or deleted — the record moves house, and if your channel lives in a git repo, history keeps every byte anyway. --dry-run shows the plan first.
  • debate post --verify-refs <repo> refuses a post whose name@sha citations don't resolve to real commits in that repo. This exists because of a real incident: a close message once cited a commit hash that was written down before the commit existed — wrong by construction, correction entry required. Machines are better at this check than authors are.

What's enforced — and what isn't

Be precise about what this tool guarantees, especially before running agents unattended:

  • Enforced, hard: turn order, one open thread at a time, message caps, the message format, and write ordering (the mailbox entry always lands before the doorbell rings, so a watcher can never read a half-written message). An agent that breaks these rules gets its post refused, not a warning.
  • Advisory, soft: everything an agent does outside the mailbox. "Don't push to main", "don't touch the config" — if those live in a prompt, you are trusting the model to comply. The tool can force when an agent speaks. It cannot force what the agent says to be true.

That second bullet is not theoretical. The one time our unattended fallback fired in production, the agent did everything right — and also repeated a stale fact from the channel history as if it were current, because it never re-checked the repo. The fix is cultural and cheap: require verdicts to cite fresh evidence (commit hash + test count), keep merges in human hands, and give unattended sessions their own working copy. The full story is in the case study.

Rules we learned the hard way

Each of these is encoded in the tool or the shipped watcher, and each one was paid for:

  1. Check for an open thread, not just the turn field — after a close, the turn field means nothing.
  2. Invoke once per doorbell change — an agent that produced no reply gets one timed retry, then the human is pinged. Two agents in a refusal loop would burn money forever; the cap is the brake.
  3. Wait before waking an agent — a human may be mid-reply; the fallback should behave like a fallback.
  4. The watcher's memory lives outside the shared folder — its state file is not part of the record and never collides with a fresh clone.
  5. The supervisor can speak at any time without taking a turn — the human interjecting never breaks the agents' alternation.
  6. The mailbox is the record — if it didn't happen in CHANNEL.md, it didn't happen. Corrections are new messages, never edits.

Why not just…

  • GitHub PRs and a review bot? Great if both agents live where your repos are hosted. debate needs no hosting service, works completely offline, and round-trips in seconds on a cron tick — no webhooks, no tokens. (If GitHub fits your setup, use GitHub.)
  • A multi-agent framework (AutoGen, LangGraph, CrewAI)? Those orchestrate agents they own, inside one program. debate coordinates agents that nobody jointly owns — different vendors, different apps, different lifetimes — and leaves a human-readable paper trail as the primary artifact.
  • A message queue? You'd be trading two greppable text files and git log for a broker you have to run. The paper trail is the point.

Limits, honestly

  • Two parties by design. A review needs a builder and a reviewer; strict alternation between exactly two named agents (plus a supervisor who can always interject) is the feature. Getting N agents to agree is a different protocol.
  • Polling, not push. The doorbell is made to be checked every few minutes by cron. If you need sub-second latency, this is not your transport.
  • The writer lock is advisory. post and compact serialize on a transient .lock file in the channel root (a crashed holder's lock is broken after 30 seconds), so two simultaneous posts cannot interleave — the second sees the first's thread open and is refused. But it only binds writers that go through the CLI; something editing the files directly isn't serialized — and shouldn't exist. (compact's crash ordering can duplicate an entry across mailbox and archive; it can never lose one.)
  • Young. Extracted from a working production setup, generalized, and tested — but read the code before trusting it; it's ~950 lines including the CLI.

Where this comes from

This is not a design exercise — it's the generalization of a channel that ran (and still runs) real code-review cycles between two commercial AI ecosystems:

  • The builder seat: Claude Code, Anthropic's terminal coding agent, running Fable 5 (their strongest model tier), on a flat-rate subscription.
  • The reviewer seat: a GPT-5.5 agent on Hermes, Nous Research's open-source agent harness, authenticated through an OpenAI Codex subscription. Hermes matters here: it is not a chat window but a full agentic environment with its own scheduler, its own subagents, and a Telegram gateway — its cron ran the watcher, and every channel message was mirrored to the supervisor's phone by the same infrastructure.

No API key existed anywhere in the system. Two subscriptions, each valid only inside its own app, collaborating through two files in a repo. A typical review round-tripped in about five minutes, most of which was the reviewer independently re-running the test suite.

One way to read that setup: an orchestrator conducting another orchestrator. The top-tier model doesn't just answer reviews — it writes the specs and test contracts, and the Hermes-side agent executes them inside its own 24/7 infrastructure, then the roles flip for review. In the best run of that shape, the stronger model authored a spec-and-tests contract, the Hermes agent implemented it, and the result — one round trip, about ten minutes — was a 137× speedup on the function under contract. debate is the baton between the two conductors, and the score everyone can read afterwards.

The same shape fits whatever pair of ecosystems you already run — Claude Code on one side; Hermes, OpenClaw, or your homegrown harness on the other. If it can read files and run a shell command, it can hold up its end of a review.

The name

Parliamentary, not adversarial: strict turns, one motion on the floor at a time, and everything said is on the record. (If you arrived from the "AI safety via debate" literature: this is not the formal debate game — it's review correspondence with teeth.)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

debate-0.2.0.tar.gz (33.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

debate-0.2.0-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file debate-0.2.0.tar.gz.

File metadata

  • Download URL: debate-0.2.0.tar.gz
  • Upload date:
  • Size: 33.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for debate-0.2.0.tar.gz
Algorithm Hash digest
SHA256 46532942da0b534939f46227100761bedccded6da1f45ce31fb6fdd9241e42f4
MD5 4e6ccace6e28ebdb1ae53d24dad7d560
BLAKE2b-256 051d399143c50ca912149cb40836a9468106d4c71822d93fd71eb93168690bc2

See more details on using hashes here.

Provenance

The following attestation bundles were made for debate-0.2.0.tar.gz:

Publisher: release.yml on zolcal/debate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file debate-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: debate-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 22.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for debate-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 775f0f87ac6e46c44f3cea51a7d3f07a0fc32698de73121681ad499ed7c5dae9
MD5 e337d32d61d3c8c42d0f69468a29ecb5
BLAKE2b-256 4f2beb6bc87573a4694ce7b72f57d7d023d86b7815d99431c281192a2d8828e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for debate-0.2.0-py3-none-any.whl:

Publisher: release.yml on zolcal/debate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page