Repository navigation
[Provider compatibility] Claude Code /compact gets stuck on 502 retries with native GPT-6.1 Sol #6504
Description
Client or integration
Claude Code CLI 2.1.288 on macOS, launched through the claude-ocx script included below. The gateway runs remotely. I haven't tried reproducing this with a fresh stock ocx claude launch yet.
Provider or upstream service
OpenAI through my ChatGPT/Codex subscription, using gpt-6.1-sol. Claude Code selects it as ocx-claude-native--gpt-6.1-sol.
OpenCodex version
@bitkyc08/opencodex 2.76.0.
Endpoint or capability
/v1/messages to native OpenAI Responses, especially input-limit errors and Claude Code's /compact command.
Current behaviour
My Claude Code session got stuck after the context grew to roughly 660k tokens. The next turn returned API Error 502 and kept retrying. I tried /compact, but that failed too, so I couldn't continue the session.
At the time, my launcher used:
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=922000
export CLAUDE_CODE_AUTO_COMPACT_WINDOW=829800Both DISABLE_COMPACT and DISABLE_AUTO_COMPACT were unset. I had copied the context values from GPT-5.6 guidance. After checking the source, I changed the maximum to 872000 for GPT-6.1 and moved compaction earlier, to 600000. The attached launcher has those corrected values.
The last successful request before the failure accepted 658,820 input tokens. I don't know the exact upstream cutoff or what caused the following request to be rejected.
I managed to recover a fork by running /compact on the same model with tools and MCPs disabled:
- Claude's recorded context went from 664,375 to 26,517 tokens.
- The native request used 632,140 input / 18,094 output tokens and returned HTTP 200.
- Compaction took about 13 minutes.
- After restoring normal tools and MCPs,
/contextsucceeded at 85.7k / 600k.
The original history is intact. I haven't reached the new automatic compaction threshold yet.
Expected behaviour
I'd expect an input-limit rejection to reach Claude Code as an error it understands, so it stops retrying the same request. /compact should either work or explain how to recover if the compaction request also exceeds the limit.
I'd also like a supported long-context setting that leaves enough room for tools and the compaction request itself.
Minimal redacted request or reproduction
I hit this in an existing session with normal tools and MCPs enabled. I haven't reduced it to a standalone payload yet.
- Launch Claude Code through the script below, using the original 922000 / 829800 values shown above, and select
ocx-claude-native--gpt-6.1-sol. - In my session, the next turn failed after input grew to roughly 660k tokens.
- Run
/compactin that session. It also fails with the input rejection and Claude retries with 502 errors.
For recovery, I used the corrected launcher, forked the session, and compacted with tools/MCPs disabled. That changed the request size. I can't yet say whether the earlier compaction setting will prevent this from happening again.
Actual response or error
Claude showed API Error: 502 and retried. The associated gateway record showed status 400, invalid_request_error, terminal_sse, payload-rejected, and protocol-prelude, with this message:
The provider rejected this turn because its input exceeds the provider size or context limit. Reduce the current input or compact the conversation before retrying.
I haven't captured a complete redacted Claude-facing wire exchange, so I can't pinpoint where this turns into a retrying 502.
Upstream documentation
I couldn't find a public specification for the exact input limit on this subscription endpoint. These are the OpenCodex references I checked:
- Claude Code alias and context-window handling.
- GPT-6/GPT-6.1 context metadata: 272k default, 872k extended ceiling/max input.
- GPT-5.6 subscription context measurements: 922k ceiling.
Suggested mapping or implementation notes
Could you check how the native input-limit error reaches Claude Code through the Messages translation? #3170 and #4112 cover similar failures in the Responses/Codex paths. I haven't confirmed whether this has the same cause.
I'd also like to select 1M context for native ChatGPT-subscription models in Claude Code, with manual and automatic compaction working. Please support that wherever the upstream model/account allows it, and show the supported maximum and compaction setting for each model. I'm currently setting both values by hand in the launcher.
I've read #3958 about the existing extended-context control and #4950 about a 1M option. GPT-6.1 currently advertises 872k, and my recovery doesn't establish that it accepts a full 1M. Could you clarify what's supported for this route and whether 1M can be added?
Additional context and attachments
Here's my current claude-ocx launcher. It loads credentials from a local claude-ocx.env file; I've left that file out. The script contains variable references for the gateway URL and token, with no embedded credential values.
claude-ocx launcher after recovery
#!/usr/bin/env bash
set -euo pipefail
ENV_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/claude-ocx.env"
if [[ -f "$ENV_FILE" ]]; then
set -a
# shellcheck disable=SC1090
source "$ENV_FILE"
set +a
fi
: "${OPENCODEX_BASE_URL:?Set OPENCODEX_BASE_URL in $ENV_FILE}"
: "${OPENCODEX_API_AUTH_TOKEN:?Set OPENCODEX_API_AUTH_TOKEN in $ENV_FILE}"
# Don't let a local Anthropic API key bypass OpenCodex.
unset ANTHROPIC_API_KEY
export ANTHROPIC_BASE_URL="$OPENCODEX_BASE_URL"
export ANTHROPIC_AUTH_TOKEN="$OPENCODEX_API_AUTH_TOKEN"
# Tell Claude Code that authentication/model access is managed by the gateway.
export CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST=1
export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1
# Summarize before the observed upstream rejection near 661k tokens.
export CLAUDE_CODE_AUTO_COMPACT_WINDOW=600000
export ANTHROPIC_DEFAULT_HAIKU_MODEL=google-antigravity/gemini-3.8-flash[1m]
export CLAUDE_CODE_AUTO_MODE_SERVER=0
export EDITOR=edit
# Native GPT-6 / GPT-6.1 input ceiling advertised by OpenCodex.
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=872000
exec claude "$@"I checked open and closed issues before filing. Related reports are #1218 (the earlier 200k fallback), #3958 (extended native context), #3170 / #4112 (input-limit and compaction errors), and #4950 (the 1M request). I didn't find an exact match for this Claude Code/GPT-6.1 failure. #4950 was closed by the template checker.
Checks
- I searched existing provider and compatibility issues.
- The request and response were redacted.
- The expected behaviour is based on an upstream specification or a concrete client requirement.
Activity
lidge-jun commentedon Oct 3, 2026
The proxy-side context-error projection is fixed in #6516, merged into
devas36330ae2ef120daa75566280f9c0b1e51eb2a36b. Classifiedcontext_length_exceededfailures now keep their code through Messages streaming and produce HTTP 400 in collected/JSON responses instead of being reclassified as retrying 502. Unknown failures, local translation limits and replay refusal remain distinct.Regression evidence includes composed canonical-native-to-Messages wire tests and an isolated real Claude Code 2.1.288 client against the proxy with a synthetic native terminal SSE response: API Error 400 was surfaced and the command terminated, with three bounded upstream requests. This does not mean zero client retries or successful automatic compaction. Required final-head PR CI passed: https://github.com/lidge-jun/opencodex/actions/runs/37132320824.
Closing the proxy error-handling bug as delivered to dev. The reporter's private long-context session and exact subscription cutoff were not replayed. This fix does not enlarge upstream limits or promise 1M input support; earlier compaction and reducing tool/MCP overhead remain relevant when the compaction request itself is too large. Recovery and verification limits are documented in the PR's Claude Code guide update. Production publication is still pending the integrated release gates.