hey_boyce on X: Codex, talking to OpenAI itself, got 400
invalid_encrypted_content "The encrypted content for item
cmp_magpie_1794916786407450000 could not be verified".
Cause: PortCodexRollouts writes magpie's compaction item (magpie1:
base64 summary) as Codex's own summary message, keeping each line's
length, since a paginated rollout keeps places by byte. A message
longer than the line (a short summary under Codex's ~400-char prefix)
was left as it was, so the magpie1: seal stayed in the rollout, Codex
replayed it to OpenAI every turn, and the thread was stuck. The
incremental pass never looked at such a rollout again.
Change:
- fitShorter: when the full message doesn't fit, the summary goes
under a short heading, then cut to fit (rune-safe, "…"), then
with no heading. If nothing fits, a standalone item is retired as
{"type":"magpie_compaction"}, which Codex reads as unknown and
never sends.
- In replacement_history an unknown item IS sent (as "other"), and
OpenAI refuses it ("Invalid value: 'other'"; seen with real
codex-cli 0.165.0 and 0.169.1). So a compaction or reasoning item
retired there is left out with its metadata entry, and
magpie_reasoning items main's PortCodexRolloutsLeft already wrote
there are taken out (retiredInList). That was a sibling bug: those
threads failed the same way.
- codex-portable.json gains refit: a state from before makes one
whole pass again, so rollouts already left with the seal are fixed.
- The gateway's last line: a 400 naming an item of magpie's own
compaction asks again with its summary message in its place
(withoutItem), not with the summary dropped.
- codexsummary.Summary decodes the seal; Message uses it.
- docs/subsystems/gateway-routing.md says all of this.
Run (on mica, at this head rebased on a265632da):
- red on the old code, green now: TestPortCodexRolloutsLongerLine
(short, cut), TestPortCodexRolloutsDropsRetiredFromHistory,
TestPortCodexRolloutsRefitsOnce,
TestPortCodexRolloutsLeftRetiresUnsealedReasoning,
TestRefusedMagpieCompactionGoesAsText (old withoutItem: 2 items,
the summary gone).
- broken by hand: without `&& was.Refit` RefitsOnce is red.
- real Codex, sandbox HOME with a copy of the owner's ChatGPT auth,
codex-cli 0.169.1, gpt-6-sol, against OpenAI:
- the reporter's item (id cmp_magpie_1794916786407450000, summary
"ok") gave the same 400 word for word. Ported by this code, resume
answered.
- an id-less item plus a magpie_reasoning in replacement_history
(as main left it) failed "Invalid value: 'other'" before. Ported,
resume answered.
- go test -count=1 -timeout 45m ./internal/codexsummary
./internal/sessions ./internal/gateway ./internal/agent: all ok
(gateway 1026s, agent 221s), log kept in enc-scratch/pkgs.log;
TestLoopGuard* again after the doc edit: ok.
- rebased on 53db3e389 (stream keepalive; only the doc page is
shared): the refusal, seal, compaction, LoopGuard and Quiet tests
in internal/gateway again at this head: ok.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./..., go build ./... ok.
Not tried: a summary cut to fit with real Codex (the unit test checks
it is a plain user message, the same shape as the case that was run);
a Codex in WSL; the full ./... suite: mote was over its cores and both mote and
mica were running another session's GUI suite, so only the changed
packages and internal/agent, which ports rollouts, ran (above).
The "magpie1:" mark, Codex's summary prefix and the reading of a magpie
compaction as Codex's own local-compaction summary message move from the
gateway into internal/codexsummary, so the rollout rewrite that comes next
(internal/sessions, which the gateway imports) reads it the same way. The
gateway's behaviour is unchanged.
Run: go build ./internal/...; go vet ./internal/gateway ./internal/codexsummary;
go test ./internal/codexsummary; go test ./internal/gateway
-run 'Compact|CodexInput|Rewrite|Native|CallItem|Protection' (ok, 57s).