ownTurn ended a Codex fork's copied head at the first turn id the parent's
file didn't hold (fb1f4856a). codex-rs names a turn that has no id of its
own "rollout-<n>" (the rollout canonicalizer's implicit turns; the
thread-history builder), and a copied head can carry one the parent's file
lacks. It was taken for the fork's first own turn, so every copied
checkpoint after it was booked as the fork's call: July and August usage
that was the parent's history over again. Reporter: SKYhuangjing, whose
fork branch codex-fork-head-marker (acb034645) this ports.
ownTurn now leaves a "rollout-" turn id alone. callParseVersions and
parseVersions raise codex to 3, so kept shards and call caches are read
again once (the same one-time re-read the codex 2 raise cost).
Changed from the patch: the code comment and the subsystem page
(docs/subsystems/gateway-sessions.md) say what codex-rs does, not what
the reporter's corpus showed; the test comment names #5090.
Checked, not changed: ZCode's fork path (zcDB.copied) matches copies by
the original message id and never reads a turn id; ownTurn has one
caller (codexUsageState.context).
Run (mote-run, at this tree on origin/main + this commit):
- TestCodexForkHeadMarkerDoesNotEndTheCopies red with ownTurn as on
origin/main (4 calls on the fork, want 1), green with the fix.
- go test -count=1 ./internal/sessions ./internal/usage ok; gofmt -l clean.
- GOOS=windows and GOOS=linux go vet ./internal/sessions clean.
Not tried: the reporter's real database (we have no copy of their
corpus). Not confirmed: codex-rs main has no writer that puts a
turn_context with "rollout-<n>" into a forked file from
record_initial_history, as the issue says; the prefix is confirmed from
the two codex-rs writers above, but which one produced the reporter's
files is unknown. Not handled: a fork whose own first turn is itself a
"rollout-<n>" (a legacy rollout migrated with no ids) still doesn't end
the copies by turn id; checkpoints still match it as before.
Full suite: run after the push, result on #5090.
Co-authored-by: SKYhuangjing <13705011+SKYhuangjing@users.noreply.github.com>
18 lines
5.5 KiB
JSON
18 lines
5.5 KiB
JSON
{"timestamp":"2026-03-24T09:30:00.500Z","type":"session_meta","payload":{"id":"019d1f2d-f9c0-7111-8222-333444555666","forked_from_id":"019d186b-a100-7aaa-8bbb-cccdddeeefff","timestamp":"2026-03-24T09:30:00.500Z","cwd":"/Users/sky/proj","originator":"codex_cli_rs","cli_version":"0.117.0","source":{"subagent":{"thread_spawn":{"parent_thread_id":"019d186b-a100-7aaa-8bbb-cccdddeeefff","depth":1}}},"model_provider":"openai","base_instructions":{"text":"You are Codex."}}}
|
|
{"timestamp":"2026-03-24T09:30:00.512Z","type":"session_meta","payload":{"id":"019d186b-a100-7aaa-8bbb-cccdddeeefff","timestamp":"2026-03-23T02:00:00.120Z","cwd":"/Users/sky/proj","originator":"codex_cli_rs","cli_version":"0.117.0","source":"cli","model_provider":"openai","base_instructions":{"text":"You are Codex."}}}
|
|
{"timestamp":"2026-03-24T09:30:00.511Z","type":"turn_context","payload":{"turn_id":"rollout-2","cwd":"/Users/sky/proj","approval_policy":"on-request","sandbox_policy":{"type":"workspace-write"},"model":"gpt-5.4","effort":"high","summary":"auto"}}
|
|
{"timestamp":"2026-03-24T09:30:00.512Z","type":"turn_context","payload":{"turn_id":"t1","cwd":"/Users/sky/proj","approval_policy":"on-request","sandbox_policy":{"type":"workspace-write"},"model":"gpt-5.4","effort":"high","summary":"auto"}}
|
|
{"timestamp":"2026-03-24T09:30:00.512Z","type":"response_item","payload":{"type":"message","role":"user","content":[{"type":"input_text","text":"review the parser"}]}}
|
|
{"timestamp":"2026-03-24T09:30:00.512Z","type":"event_msg","payload":{"type":"token_count","info":{"total_token_usage":{"input_tokens":41200,"cached_input_tokens":3072,"output_tokens":812,"reasoning_output_tokens":256,"total_tokens":42012},"last_token_usage":{"input_tokens":41200,"cached_input_tokens":3072,"output_tokens":812,"reasoning_output_tokens":256,"total_tokens":42012},"model_context_window":258400},"rate_limits":{"primary":{"used_percent":5.0,"window_minutes":300,"resets_in_seconds":1200},"secondary":{"used_percent":42.0,"window_minutes":10080,"resets_in_seconds":400000},"credits":null,"plan_type":"pro"}}}
|
|
{"timestamp":"2026-03-24T09:30:00.512Z","type":"response_item","payload":{"type":"message","role":"assistant","content":[{"type":"output_text","text":"Looking."}]}}
|
|
{"timestamp":"2026-03-24T09:30:00.512Z","type":"event_msg","payload":{"type":"token_count","info":{"total_token_usage":{"input_tokens":84880,"cached_input_tokens":44160,"output_tokens":1500,"reasoning_output_tokens":400,"total_tokens":86380},"last_token_usage":{"input_tokens":43680,"cached_input_tokens":41088,"output_tokens":688,"reasoning_output_tokens":144,"total_tokens":44368},"model_context_window":258400},"rate_limits":{"primary":{"used_percent":5.0,"window_minutes":300,"resets_in_seconds":1200},"secondary":{"used_percent":42.0,"window_minutes":10080,"resets_in_seconds":400000},"credits":null,"plan_type":"pro"}}}
|
|
{"timestamp":"2026-03-24T09:30:00.512Z","type":"turn_context","payload":{"turn_id":"t2","cwd":"/Users/sky/proj","approval_policy":"on-request","sandbox_policy":{"type":"workspace-write"},"model":"gpt-5.4","effort":"high","summary":"auto"}}
|
|
{"timestamp":"2026-03-24T09:30:00.512Z","type":"response_item","payload":{"type":"message","role":"user","content":[{"type":"input_text","text":"now fix it"}]}}
|
|
{"timestamp":"2026-03-24T09:30:00.512Z","type":"event_msg","payload":{"type":"token_count","info":{"total_token_usage":{"input_tokens":131072,"cached_input_tokens":88832,"output_tokens":2400,"reasoning_output_tokens":512,"total_tokens":133472},"last_token_usage":{"input_tokens":46192,"cached_input_tokens":44672,"output_tokens":900,"reasoning_output_tokens":112,"total_tokens":47092},"model_context_window":258400},"rate_limits":{"primary":{"used_percent":5.0,"window_minutes":300,"resets_in_seconds":1200},"secondary":{"used_percent":42.0,"window_minutes":10080,"resets_in_seconds":400000},"credits":null,"plan_type":"pro"}}}
|
|
{"timestamp":"2026-03-24T09:30:00.512Z","type":"response_item","payload":{"type":"message","role":"assistant","content":[{"type":"output_text","text":"Fixed."}]}}
|
|
{"timestamp":"2026-03-24T09:30:00.512Z","type":"response_item","payload":{"type":"function_call_output","call_id":"call_fork1","output":"You are the newly spawned agent. The prior conversation history was forked from your parent agent. Treat the next user message as your new task, and use the forked history only as background context."}}
|
|
{"timestamp":"2026-03-24T09:30:01.000Z","type":"turn_context","payload":{"turn_id":"t4","cwd":"/Users/sky/proj","approval_policy":"on-request","sandbox_policy":{"type":"workspace-write"},"model":"gpt-5.4","effort":"high","summary":"auto"}}
|
|
{"timestamp":"2026-03-24T09:30:01.010Z","type":"response_item","payload":{"type":"message","role":"user","content":[{"type":"input_text","text":"check the docs"}]}}
|
|
{"timestamp":"2026-03-24T09:30:12.000Z","type":"event_msg","payload":{"type":"token_count","info":{"total_token_usage":{"input_tokens":178400,"cached_input_tokens":133504,"output_tokens":2950,"reasoning_output_tokens":560,"total_tokens":181350},"last_token_usage":{"input_tokens":47328,"cached_input_tokens":44672,"output_tokens":550,"reasoning_output_tokens":48,"total_tokens":47878},"model_context_window":258400},"rate_limits":{"primary":{"used_percent":5.0,"window_minutes":300,"resets_in_seconds":1200},"secondary":{"used_percent":42.0,"window_minutes":10080,"resets_in_seconds":400000},"credits":null,"plan_type":"pro"}}}
|
|
{"timestamp":"2026-03-24T09:30:12.100Z","type":"response_item","payload":{"type":"message","role":"assistant","content":[{"type":"output_text","text":"Docs ok."}]}}
|