When magpie answers Codex's compaction itself (a magpie model, Codex's
own models through magpie's accounts, a CC Switch table), the item it
returns carries encrypted_content "magpie1:"+base64(summary). Codex keeps
it in the rollout (a response_item, and the compacted checkpoint's
replacement_history) and replays it with every later turn. Sent to the
ChatGPT backend directly, it is refused: "The encrypted content for item
cmp_magpie_1 could not be verified ... invalid_encrypted_content"
(probed with a real request on gpt-5.6-luna; the same summary as a user
message was answered).
Codex's remote compaction v2 keeps exactly one Compaction item, so magpie
can't answer with a plain message instead. sessions.PortCodexRollouts
writes each of magpie's items in a rollout as the message it stands for
(codexsummary.Message: Codex's summary prefix, a newline and the summary,
as a user message), which is what Codex's own local compaction stores and
what the gateway already sends in its place, so it reads the same through
magpie and goes on without it.
- Only magpie's compaction items change; other lines keep their bytes,
the file its line count, mode and time. An unreadable one is left out
of a list with its replacement_history_metadata entry, as Codex's own
ghost-snapshot strip does.
- Published as Codex publishes a compressed rollout: temp file and
rename, under thread-writer-locks/.coordination.lock and only with the
thread's lock free. A thread a Codex has open is left for a later pass.
A Codex home without thread-writer-locks is left alone.
- .jsonl.zst rollouts are read and written packed.
- Passes: 2 minutes after the GUI or magpie serve starts and every 10
minutes; on Codex Disconnect (3s); as the GUI quits (3s). The first
pass reads rollouts written since 2026-09-24; later ones only what
changed since the last whole pass, plus what was left held
(codex-portable.json in magpie's folder).
Run at this series' head (on origin/main 0fe039f14):
- Real codex 0.162.1, sandbox HOME/CODEX_HOME, exec </dev/null, against a
fake upstream. In magpie mode it auto-compacted and the rollout's
compacted line held magpie1:. In OpenAI mode, `exec resume --last`
failed with "Error running remote compact task: ...
invalid_encrypted_content". After PortCodexRollouts on that home, only
that line changed (42 lines before and after). The same resume exited
0, and the upstream saw the summary message.
- Broken by hand. With the thread-lock TryLock check off,
TestPortCodexRolloutsLeavesAnOpenThread went red. With the replacement
off, TestPortCodexRollouts went red. Both green with the fix restored.
- gofmt -l clean. go vet ./... (darwin) clean, GOOS=windows go vet
./internal/... clean, and GOOS=linux go vet -tags nogui ./... clean.
- go test ./... -count=1 -timeout 45m: 64 packages ok, two reds.
- internal/agent ran out of time at 2706s (load average 25 to 57), the
known #2723/#2544. Alone, go test ./internal/agent -count=1 is ok in
901s.
- internal/provider TestHoldReadsMigrationsOnce: "migrations.json read
again while held" at 2.70s. It passes alone 5 of 5. I didn't touch
that package. Filed #3095: heldFor (1s) can run out between the
test's two reads.
Not tried:
- api.openai.com itself after a port. The refusal was probed on the
ChatGPT backend, and the resume ran against a fake.
- A Codex in a WSL distro. Disconnect skips it, because its locks can't
be taken from Windows.
- The Codex app still holding a thread when magpie quits. Its lock is
held, so the file is left for the next pass, and the thread in that
app's memory keeps the magpie1 item until it is loaded again.