A Codex replaying its whole conversation itself (store false, no
previous_response_id) echoes ids the upstream handed out for earlier
turns. When an upstream turns one away as another of its resources' —
the prevForeign refusal — the recovery that strips such ids from a
conversation magpie gave back never ran: the store-off request hung no
ask, so the retry gate stayed shut and the 400 reached the client
(#6320). x1051445024's report; the reporter's own compat proxy stripped
whitelisted optional ids as a workaround.
The store-off request now carries a marked ask when its input reads as a
replayed conversation: more than one item, and one before the last
naming an id that may go without one, or a reasoning's. One id'd item
alone is the client's own new input and goes as it came, as
TestPreviousResponseOtherResourceWholeSentWithoutIDs already holds the
line. On the foreign refusal the same prevElsewhere run takes those ids
out of the replay — reasoning only with its encrypted_content, calls'
call_id pairing kept — and the request is asked again once, only with a
body that differs. Nothing is recorded for a store-off request, and a
known conversation's recovery is exactly as before (the mark is never
set on an ask magpie answered).
Verification on darwin/arm64, upstream/main 873b4987e + this commit:
- New TestClientWholeReplayForeignIDsAskedWithoutThem fails on the
unmodified base with the 400 reaching the client, passes with this
commit (2 upstream calls: the refusal, then the replay without ids);
TestClientWholeSingleIDedItemStaysAsItCame holds the single-item line.
- The existing prev family stays green, the two boundary tests included.
- Ablation: the three hunks reverted (ask hang, prevClientWhole gate,
prevElsewhere's client-whole treatment), tests kept, the replay test
red again; restored, green.
- internal/gateway whole package green; gofmt/vet clean.
Fixes#6320
Generated-by: GLM-5.3-Flash (ZCode)
Landed by the maintainer after (mote, darwin/arm64):
- this change's file(s) reverted with its tests kept: its new tests red;
restored, green
- full suite (go test -tags nogui ./... -timeout 45m) with the stack on
0b8c4bfc3: every package ok but two reds of that base, fixed on main
since (4c86b0ab4 cli route parity, e9fcc6229 tui "permission mode")
- rebased on f1c9014cd: go test of internal/gateway, internal/plugin,
internal/cli and internal/tui ok; go vet darwin, linux nogui, windows ok