ac4af582301a4e8a29245dbba767eba31334ddf9
5
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
bd5152ce3b |
sessions: a Codex rollout with nothing to change is only read, never written out again (#4735)
portRollout and repairLineages ran every rollout they looked at through editRollout, which opened a temp file (and a zstd encoder for a packed one) and wrote the whole rollout out before it could know whether any line changed; a rollout with nothing to change was then thrown away. On every pass over ~/.codex/sessions that was a full rewrite per file. editRollout now reads first (eachEditedLine with no writer, which stops at the first line that changes) and only then makes the temp file and the encoder. If the second, writing pass changes nothing the file moved between the reads and is held (errRolloutHeld), as a stat change already was. The edit is built afresh per pass, so per-file state (portRollout's "ours") starts over. Lines are read with ReadSlice into a 64KB buffer; a longer line is gathered whole. The encoder is closed on every early return now; it was left open before. Run on mote (macOS 27.2), 10 rollouts of 4MB each with nothing to change: - plain: 686ms -> 106ms per pass, 46MB -> 0.66MB allocated, 232k -> 120 allocations. - zst: 127ms -> 120ms per pass, 237MB -> 0.67MB allocated; the process's CPU (with the same setup) 2.55s -> 1.43s, sys 0.6s -> 0.17s. - TestPortCodexRolloutsOnlyReadsWhatHasNothingToChange, plain and zst, with a 300KB line: nothing written out and the bytes the same; then with one line to change it is rewritten, the long line kept. With the reading pass taken out by hand it fails: "1 rollouts written out for nothing". - TestPortCodex* and TestPortLine*: ok. - go test ./internal/sessions ./internal/agent: ok (36.7s, 228.9s). - GOOS=windows and GOOS=linux go vet of both: ok. gofmt -l: clean. Not tried: a real ~/.codex/sessions pass in the app; the numbers are the benchmark's, not a sample of the reporter's machine. |
||
|
|
47173f593a |
sessions: a Codex thread left magpie keeps no reasoning OpenAI didn't seal
hentulong on X: after routing Codex through WorkBuddy and switching back,
Codex couldn't connect, and a fork said "Persisted response contains
hosted-tool, compaction, or unverifiable hidden reasoning state that
Rustponses cannot replay".
Cause: while Codex is routed through magpie to another vendor, the
reasoning items magpie hands it stay in the thread's rollout. After the
switch back Codex talks to chatgpt.com itself, and OpenAI refuses every
reasoning item it didn't seal. On the owner's real account:
- summary only, no encrypted_content: unsupported_persisted_item_context
(the reporter's Rustponses error) on a previous_response_id
continuation;
- with content (reasoning_text, what Codex 0.165 writes for DeepSeek via
magpie): 400 array_above_max_length "Invalid 'input[5].content'";
- foreign encrypted_content: invalid_encrypted_content.
Codex treats each as fatal, so that thread and its forks fail while new
threads work. No stale config: Unwire/EndFailover drop openai_base_url.
Fix: when Codex is no longer routed or failing over (Unwire, quit,
uninstall and the periodic pass), PortCodexRolloutsLeft rewrites, in
threads begun on openai/magpie, every reasoning item (and every one in a
compacted line's replacement_history) whose encrypted_content isn't an
OpenAI Fernet token ("gAAAA") into type "magpie_reasoning", without id
and encrypted_content. Codex reads an unknown type as Other and never
sends it; magpie's sessions readers still show it. The edit keeps member
order and line length (same fitLine/lock path as the existing port),
has its own state entry, and starts at 2026-09-21. A survey of 150 live
rollouts found 340 of 340 OpenAI reasoning items in the gAAAA shape.
Run (mote, at
|
||
|
|
67b12956ac |
sessions: a Codex rollout magpie rewrites keeps every line where it was
xybio (Discord #feedback): the Codex app often wouldn't reopen recent threads: "invalid paginated history lineage for <id>: cutoff byte offset is past the source rollout". Codex 0.162 keeps a fork's place in its parent by byte (session_meta.history_base.end_byte_offset, checked by rollout_lineage.rs validate_cutoff_bounds), and its state database keeps turns and how far it has read by byte too. PortCodexRollouts (since |
||
|
|
79c8667c92 |
gateway: Codex gives Claude its signed thinking back through encrypted_content
Codex calling a Claude model through magpie (mysterious_dove_96933 on
Discord): a reply's reasoning items carried only the summary, so Claude's
thinking signature and a redacted_thinking block's data were gone. On
the next request of a tool loop magpie sent Anthropic the turn as
[tool_use] alone, with thinking on, which Anthropic documents as a 400
("final assistant message must start with a thinking block"), and the
model lost its reasoning across calls either way.
Now the Anthropic decoders name a signature as Claude's (KSig with
sealAnthropic, Part.SignedBy). The Responses encoder and renderResponses
give each thinking block a reasoning item whose encrypted_content is
"magpie-claude1:" and the block's JSON in base64 (internal/claudeseal):
its summary beside it, an empty summary for a block signed with no
text, and redacted_thinking as an item of its own. parseResponses reads
it back into the block as Claude wrote it, in order, so anthropicBody
sends it as before for an Anthropic client. A Gemini thought's
signature isn't named and isn't sealed.
The envelope never reaches a Responses API: withoutClaudeSeals in
passthrough and forwardOnce (the item keeps its summary, one with none
goes), codexInputAs leaves such an item out for Codex's own models, and
codexUpstreamOn takes it out before the ChatGPT backend. OpenAI's own
encrypted_content is untouched. sessions.PortCodexRollouts writes such
an item as its summary, so a thread resumed against OpenAI itself isn't
refused. redact.MaskJSON already keeps a reasoning item's seal whole
(no change); TestMaskJSONKeepsClaudeBlocks holds that.
Run, at
|
||
|
|
4896fc3ba1 |
codex: a thread magpie compacted goes on after magpie is quit or disconnected (LukeMa on X)
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
|