Files
magpie/docs
yetone 6e6da86c81 gateway: POST /v1/responses/compact is relayed to a provider whose own API is Responses (#7281)
Pi's Responses compaction extension sends OpenAI's unary
POST /v1/responses/compact. Before this change, the generic route
answered it with the 404 for an unknown path and never reached the
upstream.

/v1/responses/compact and /responses/compact (responses_compact.go)
now go through serveAgent and serve, so the key, account and model
holds apply as they do on /responses. The request is marked unary
compact, and the candidates are cut to a key's provider that asks the
model on Responses (compactsUnary: no account, carriesCompaction).
attempt relays it as it came (keep, never translated), and passthrough
sends it to <Responses base>/responses/compact. The unary
response.compaction object goes back untouched, sealed item included.
compactionWatch records who wrote the sealed item, so a later
/responses that carries it goes back to that provider (#1099). The
call is recorded as KindCompact. When no candidate is left, the client
gets a 400 invalid_request_error: "/responses/compact is not supported
for <model>: ... compact on /responses instead". This follows the
CodexPath wording and gives the client a fallback. handle's
codexCompact branch is not on this path, so an earlier compaction item
in the input stays the client's. protoOfPath shapes key-limit errors
on the route as Responses errors.

Not changed: ChatGPT, Copilot and plugin accounts are refused on this
route until a real account is tried (#7285). Codex's own compact still
goes through CodexPath.

Run (mote, at this tree):
- the new TestResponsesCompactRelayed and
  TestResponsesCompactRefusedOffResponses: red on origin/main 7dc85f26e
  (404 not_found_error, both paths), green here.
- go test ./internal/gateway -run
  'TestResponsesCompact|TestCodexCompactionTriggerOnV1|NativeCompaction|KeyLimit':
  ok.
- go vet ./internal/gateway on darwin, linux and windows: ok. gofmt -l:
  clean.
- go test ./internal/gateway -count=1 -timeout 45m: started at this tree
  and not finished at push. The result will go on #7281.
Not tried: a real Pi compaction against a real Responses upstream.
2026-11-20 11:20:46 +08:00
..