Commit Graph
1 Commits
Author SHA1 Message Date
yetoneandMmx233 ff415f39cb gateway: a compaction refused for an input kind it doesn't take is asked again as text (#5181, #5259)
Command Code's /responses takes messages, function calls, their outputs
and reasoning only. A Codex subagent's compaction carries agent_message,
custom_tool_call and compaction_trigger items, and Command Code answered
400 unsupported_input_item (param input). codexCompact didn't count that
as a reason to ask again with the conversation as text, so the 400 went
back to Codex three times and compactFails held the conversation for
5 minutes.

inputKindRefused now asks again as text on unsupported_input_item or
"unknown item type" (Grok's 422) in a 400, 422 or 502 (another magpie in
front wraps it), or in a stream's error / response.failed event. A 401,
403 or 429 with the same words still goes back as it came. itemText
reads an agent_message as the user's turn, so the subagent's task and
follow-ups are in the text summary and in the local one.

No plugin change: the Command Code plugin passes /responses through, and
the fallback covers it direct, through a remote magpie and in a stream.

Run (mote):
- go test -run 'TestCodexCompact|TestCodexCompacts|AgentMessage' ./internal/gateway: ok
- go test -timeout 45m -count=1 ./internal/gateway: ok (809.6s)
- gofmt -l clean; go vet ./internal/gateway native, GOOS=linux -tags
  nogui and GOOS=windows: ok
Broken by hand:
- origin/main's codex_backend.go: every AsksAgainAsText subtest red
  (400 / 502 back to Codex).
- agent_message case removed: the text lacks the subagent's task.
- status guard loosened: the 401/403/429 test red.
Not tried: a real Command Code account (the keys on this machine are
answered 401), the reporters' own sessions; why the compaction reached
/responses rather than chat is not confirmed.

Reported-by: Mmx233 <36563672+Mmx233@users.noreply.github.com>
Reported-by: Edward4226 <Edward4226@users.noreply.github.com>
Reported-by: mahiro233 (Discord)
Co-authored-by: Mmx233 <36563672+Mmx233@users.noreply.github.com>
2026-11-06 16:04:03 +08:00