SIGN IN SIGN UP

Fix ChatGPT subscription compaction (#62547)

ChatGPT Subscription compaction currently uses the legacy `POST
/responses/compact` endpoint. The Codex backend now returns `404 Not
Found` from that route, which causes manual and threshold-triggered
compaction to fail even though ordinary model requests continue to work.

Use the current Codex compaction contracts over the normal streamed
`POST /responses` endpoint instead. Automatic compaction now advertises
server-side support and sends `context_management`, while manual
compaction appends the transient `compaction_trigger` input item used by
Codex's remote compaction v2 flow. Both paths consume the standard
encrypted `compaction` output item, preserving backend-owned state for
subsequent requests.

The manual action remains available through
`supports_explicit_compaction`; only its transport changes. The shared
Responses input type gains the `compaction_trigger` wire item and an
append operation for provider-specific request construction.

Testing performed:

- `cargo nextest run -p open_ai -p openai_subscribed --lib`
- `./script/clippy -p open_ai -p openai_subscribed`
- `cargo fmt -p open_ai -p openai_subscribed -- --check`
- Verified with ChatGPT OAuth against `gpt-5.6-sol`, `gpt-5.6-terra`,
`gpt-5.6-luna`, `gpt-5.5`, `gpt-5.4`, and `gpt-5.4-mini`:
`compaction_trigger` returned HTTP 200 with a streamed `compaction` item
for every model; forced `context_management` compaction also returned
HTTP 200 for every model. The legacy `/responses/compact` route returned
HTTP 404 for every model.

Release Notes:

- Fixed ChatGPT Subscription context compaction failing with an API
endpoint error.
C
Conrad Irwin committed
c05e34637b4f7f100a688bf6ac71cb70877fc8ad
Parent: ba0e2a9
Committed by GitHub <noreply@github.com> on 8/12/2026, 9:10:44 PM