Docs/How it works

How it works

This explains why switching a conversation between agents is possible, and what literally happens when you press Ctrl-B c.

The file is the memory

Agent CLIs are stateless between turns. Every time they start, or resume, they reconstruct the whole conversation by reading a transcript file on disk:

~/.claude/projects/<cwd-slug>/<id>.jsonl
~/.codex/sessions/YYYY/MM/DD/rollout-<timestamp>-<id>.jsonl

The running process holds no durable memory. The file is the memory. So a switch never touches a live process. It is:

  1. Stop the outgoing agent.
  2. Write a session file to disk.
  3. Start a fresh target agent that reads that file at startup.

The target cannot tell a transcript it wrote from one Constant wrote, because resuming is always "read this file and rebuild context from it."

No replay window

When the target boots, the transcript sits in its context as dormant text. Nothing is absorbed until you send your next message. And that is exactly what happened on every turn anyway: the model has no memory between turns, so each turn the entire transcript is re-read from scratch. The target's first turn after a switch is processed identically to the source's fiftieth turn.

The one real artifact: a freshly resumed session is a prompt-cache miss, so the first reply after a switch can be a beat slower. After that, normal.

It is cheap

A switch runs zero model inference: no embeddings, no API calls, no summarization. It is a deterministic text transformation: read a file, parse JSON lines, map a list, run a redaction pass, write a file. Milliseconds.

It is format-precise

The target's loader is a strict parser. Every record must have the fields the parser expects. Miss one and it rejects the entire file. Match them all and it loads flawlessly. This is why Constant matches each runtime's native session schema field by field. See The alembic cartridge.

What happens on Ctrl-B c (codex to claude)

1. The host sees Ctrl-B then c.
2. It stops the codex child.
3. alembic distills the active codex session:
   - find the session codex is currently in (newest rollout in the cwd)
   - load it into a neutral thread model
   - drop tool / reasoning events and scaffold turns, redact secrets
   - write it into Claude's native session schema
4. It runs `claude -r <id>` in the same directory.
   Claude boots, reads the file, and continues the conversation.

The reverse (Ctrl-B x, claude to codex) is the same pipeline mirrored. Codex also needs a state_5.sqlite row to resume and to appear in its /resume picker, which Constant writes too.