Skip to content

fix(proxy):-restore-compaction-after-ChatGPT-retired-the-responses-compact-endpoint - #1715

Open
WangErgouaaaa wants to merge 2 commits into
Soju06:mainfrom
WangErgouaaaa:pr/compact-protocol-fix
Open

fix(proxy):-restore-compaction-after-ChatGPT-retired-the-responses-compact-endpoint#1715
WangErgouaaaa wants to merge 2 commits into
Soju06:mainfrom
WangErgouaaaa:pr/compact-protocol-fix

Conversation

@WangErgouaaaa

Copy link
Copy Markdown
Contributor

Summary

ChatGPT retired the dedicated compact endpoint /backend-api/codex/responses/compact on 2026-08-12 18:44 UTC. Every compaction request through codex-lb has 404'd since then, regardless of client version or account — compaction is fully broken on the current release.

This PR restores compaction by serving it through the plain /codex/responses endpoint with the current v2 protocol:

  1. fix(proxy): serve compaction via plain responses endpoint — route compact requests to /codex/responses, force stream: true, set store: false explicitly (the plain endpoint rejects requests without it with 400 Store must be set to false), and re-append the terminal compaction_trigger input item that the API layer strips before the compact service.
  2. fix(proxy): restore compaction trigger and collect streamed output items — the upstream compaction result is delivered via SSE response.output_item.done events (the response.completed payload has an empty output array). Fold those events back into the legacy response.compact payload, preserving encrypted_content, so the API layer's compaction validation passes (otherwise 502 Compact response did not include a compaction output item).

Protocol notes

  • New protocol (verified against chatgpt.com on 2026-08-13): plain POST /codex/responses + stream: true + store: false + terminal {"type":"compaction_trigger"} input item + x-codex-turn-metadata: {"request_kind":"compaction"} header.
  • The compaction item arrives as {"id":"cmp_...","type":"compaction","encrypted_content":"..."} inside response.output_item.done events, ordered by output_index.
  • Client side (codex CLI) needs no changes — compact_remote_v2 already speaks this protocol.

Testing

  • Full-path verification through the proxy: HTTP 200 with a compaction event stream; request logs record compaction success.
  • Unit-tested the SSE fold-back against captured real upstream traffic.

WangErgouaaaa and others added 2 commits August 13, 2026 16:12
ChatGPT retired /backend-api/codex/responses/compact on 2026-08-12;
compaction is now served as a streamed plain /codex/responses request.
- forward compact upstream to /codex/responses with stream=true
- require explicit store=false (plain endpoint rejects absent store)
- fold the upstream SSE stream back into the legacy response.compact shape

Co-Authored-By: Claude <noreply@anthropic.com>
The plain responses endpoint only recognises compaction through a terminal
compaction_trigger input item, which the API layer strips before the compact
service - restore it for the upstream call. Also, streamed responses carry
output items in response.output_item.done events while response.completed
echoes an empty output array, so collect items by output index when folding
the SSE stream back into the response.compact shape.

Co-Authored-By: Claude <noreply@anthropic.com>
@WangErgouaaaa WangErgouaaaa changed the title fix-compact-restore fix(proxy):-restore-compaction-after-ChatGPT-retired-the-responses-compact-endpoint Aug 13, 2026
@Komzpa

Komzpa commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Status note: the compact-endpoint retirement fix this PR addresses now lives in #1749 (the #1705 line was folded there). Keeping this open until that lands; if #1749 merges first, this can close as covered. Thanks for the report and fix — the shipped implementation follows the same approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants