Repository navigation
Description
What version of Codex is running?
codex-cli 0.154.0 (also reproduced via Codex Desktop 0.154.0-alpha.6.2)
What issue are you seeing?
When a session that has gone through auto-compaction is resumed (or handed off) with a third-party model provider using wire_api = "responses", every request fails with:
{"error":{"code":"invalid_request_error","message":"invalid_request_error: invalid_request_error: input.12: item type \"compaction\" is not supported","type":"invalid_request_error"}}
The provider is Kimi for Coding (https://api.kimi.com/coding/v1), which implements a Responses-compatible endpoint. The same problem presumably affects any non-OpenAI Responses-compatible provider.
Root cause
On resume, Codex replays the persisted rollout history into input verbatim. Sessions that were compacted contain an item like:
{"type":"compaction","id":"cmp_...","encrypted_content":"gAAAAAB..."}compaction is an OpenAI-private item type — the encrypted_content is only meaningful to OpenAI's backend. Third-party "Responses-compatible" endpoints implement the public item subset (message, function_call, reasoning, ...) and reject unknown item types, so the whole request is rejected and the thread can never be continued with that provider.
This makes switching an existing (compacted) thread between OpenAI models and third-party providers impossible. Note that wire_api = "chat" is no longer an escape hatch since it was removed (#7782).
Steps to reproduce
- Configure a third-party provider with
wire_api = "responses"(e.g. Kimi for Coding). - Have a session that went through auto-compaction with any model (the rollout contains a
compactedrecord / acompactionresponse item). - Resume the session with the third-party model (
codex exec resume <id> "...", or switch the model of an existing thread in Codex Desktop). - Every turn fails with
item type "compaction" is not supported.
What is the expected behavior?
Codex should not send OpenAI-private item types to providers that can't understand them. When the active provider is not OpenAI, history replay should strip compaction items (or downgrade them to a plain text message such as "[earlier context was compacted]"), the same way the local summary bridge messages are already plain text.
Additional information
Verified workaround: a localhost proxy that rewrites input items of type: "compaction" into a placeholder message item makes resume work with the third-party provider (all requests return 200 and the thread continues normally), which confirms the only blocker is this item type being forwarded as-is.
Activity
keleqnma commentedon Sep 14, 2026
I have a fix ready for this on a branch: https://github.com/keleqnma/codex/tree/fix/strip-compaction-for-third-party-providers (compare: main...keleqnma:codex:fix/strip-compaction-for-third-party-providers)
I currently can't open the PR myself — GitHub rejects pull request creation from my account on this repo ("keleqnma does not have the correct permissions to execute CreatePullRequest" via API; the compare page says PRs are limited to collaborators). Happy to open it once that clears, or a maintainer can pull the branch directly.
Fix summary
In
build_responses_request(codex-rs/core/src/client.rs), when the active provider is not OpenAI, dropResponseItem::CompactionandResponseItem::ContextCompactionitems from the request input before sending:This is lossless for third-party providers: the compaction summary is already present in history as a regular plain-text user message, so no information visible to a non-OpenAI backend is removed. OpenAI providers keep receiving the items unchanged.
Testing
Added
responses_request_strips_openai_private_compaction_items_for_third_party_providersincodex-rs/core/src/client_tests.rs, verifying:just fmtandgit diff --checkpass.ChildOfAnAndroid commentedon Oct 7, 2026
Reproduced on Codex CLI 0.161.0 on macOS when cold-resuming an OpenAI-originated thread under Ollama/Qwen.
Setup:
--oss --local-provider ollama -m qwen3.6:27b-coding-mxfp8This is now especially clear from Ollama's current implementation. Ollama intentionally treats
compaction.encrypted_contentas provider-owned state: its payload must decode to{"type":"ollama_compaction","version":1,...}; foreign/OpenAI opaque compaction content is rejected with the exact error above inopenai/responses_compact.go.Ollama's Codex Desktop proxy already has the reciprocal compatibility behavior in
internal/proxy/codex_desktop_normalize.go: when routing to Ollama it retains only Ollama-owned compaction items and drops foreign ones; when routing to OpenAI it drops Ollama compaction state.The raw Codex CLI Ollama provider path does not go through that proxy, so Codex still forwards the persisted OpenAI compaction item verbatim.
I also verified a recovery in the same thread: after a plaintext context checkpoint was established and a fresh local compaction completed, continuation under Ollama worked. So the local provider/compactor itself is fine; the poison is specifically the replayed foreign compaction payload.
The request-boundary fix proposed above remains the minimal interoperability fix. For remote-v2 compactions, a stronger lossless approach would be to avoid selecting an incompatible persisted compaction checkpoint when the producer
compaction_model_hashdiffers from the resumed model/provider, replay the retained rollout history instead, and let the new provider compact it into its own format. That avoids treating provider-specific encrypted state as portable.