`/responses/compact` sends `service_tier` when provider-scoped API-key auth is used
What version of Codex CLI is running?
0.130
What subscription do you have?
api
Which model were you using?
gpt-5.5
What platform is your computer?
Linux 6.13.2-0_fbk7_0_gbc14455e13aa x86_64 x86_64
What terminal emulator and version are you using (if applicable)?
_No response_
Codex doctor report
What issue are you seeing?
Auto/manual compact can fail because Codex sends service_tier to /responses/compact:
Error running remote compact task: {"error":{"code":"invalid_request_error","message":"Pipeline execution failed: provider error (HTTP 400): Unknown parameter: 'service_tier'.","param":null,"type":"invalid_request_error"}}
This appears to happen when the active model provider uses provider-scoped command/bearer auth. The actual request auth is API-key-like, but compact decides whether to include service_tier using the session-level auth manager.
What steps can reproduce the bug?
- Configure Codex to use a model provider with provider-scoped command/bearer auth (
ModelProviderInfo.auth), so the provider request path usesAuthManager::external_bearer_only(...). - Configure a non-empty
service_tier. - Start interactive Codex CLI/TUI.
- Trigger manual or auto compact.
- Observe that
/responses/compactreceivesservice_tierand can fail withUnknown parameter: 'service_tier'.
What is the expected behavior?
/responses/compact should not include service_tier when the actual resolved provider/request auth does not support it.
More generally, compact request compatibility should be based on the auth/provider setup used for that compact request, not only on the session-level auth manager.
Additional information
The current compact setup decides whether to pass service_tier here:
service_tier: if sess.services.auth_manager.auth_mode() == Some(AuthMode::ApiKey) {
None
} else {
turn_context.config.service_tier.clone()
},
That assumes sess.services.auth_manager.auth_mode() reflects the auth mode of the request sent to /responses/compact.
However, provider-scoped auth can replace the request auth later. In the configured provider path:
Some(config) => Some(AuthManager::external_bearer_only(config)),
and BearerTokenRefresher reports:
fn auth_mode(&self) -> AuthMode {
AuthMode::ApiKey
}
So the actual compact request can be API-key/bearer-authenticated even when the session-level auth manager is not AuthMode::ApiKey.
Potential fixes:
- Move the
service_tierdecision closer toModelClient::compact_conversation_history, aftercurrent_client_setup(), and base it on the actual resolved provider/request auth. - As a safer short-term fix, omit
service_tierfrom/responses/compactby default, or gate it until compact endpoint support is confirmed.
11 Comments
Confirming this on Codex Desktop App for Windows, build
26.513.4821.0(Microsoft Store), against Azure AI Foundry (/openai/v1,api-version=preview,wire_api = "responses").Auto-compact reliably fails with the same payload:
Relevant
config.toml:No
service_tieris set anywhere inconfig.toml— it is injected by the compact request path itself. Matches the analysis in the original report: the provider uses bearer/API-key auth viaquery_params/env_key, soservice_tiershould be omitted for this provider.Practical impact for Azure-only users: long sessions cannot be auto-compacted, which forces manual
/compactand eventually session restart. The "safer short-term fix" proposed in option 2 (omitservice_tierfrom/responses/compactby default until endpoint support is confirmed) would be very welcome for the Azure path.Proposed fix prepared on a fork:
BSG2000/codex@fix/compact-omit-service-tier-for-provider-bearer-auth.Diff is a single file (
codex-rs/core/src/compact_remote.rs, +25/−1) and follows the option-1 fix outlined above — move the decision off the session-level auth manager and base it on the resolved provider configuration:commit c6a2548/ diff viewThis covers both the original
ModelProviderInfo.authcase and the broaderenv_key/experimental_bearer_token/awspaths that show the same symptom (e.g. an Azure provider withenv_key = "AZURE_OPENAI_API_KEY"running on Codex Desktop26.513.4821.0).Cherry-pick if useful:
I attempted to open this as a PR via the API but
CreatePullRequestis blocked for my account on this repo — likely an org-level policy. Happy to retry via the web UI if maintainers prefer, or for an OpenAI engineer to take this directly.Notes:
just fmt/cargo test/cargo instalocally (no Rust toolchain in the environment I prepared this from).remote_manual_compact_api_auth_omits_service_tier_and_reuses_prompt_cache_key(added in #21676) only exercisesCodexAuth::from_api_keydirectly, not provider-side bearer paths. A follow-up that extendsassert_remote_manual_compact_request_parityto configureModelProviderInfo.auth/env_key/experimental_bearer_tokenwould catch regressions here.https://github.com/openai/codex/issues/21671#issuecomment-4467060518
---
service_tierparameter from remote compaction requests---
A naive (it disables
service_tiereven for non-Azure remote compaction) patch can be seen here:https://github.com/Elefunc/codex/commit/c0581fc0a4da98bff5c3832ddc91fb24679ac8e8
---
You can create an Azure-only script/alias and use it like this
ask Codex to create
ca.model.jsonfor you!---
---
---
https://github.com/openai/codex/issues/21671#issuecomment-4497122032
---
0.132.0still has the same issue!My patches against
0.132.0that special-case Azure connections:https://github.com/Elefunc/codex/commit/71057e6abccd11186674888f7c8bf2991fe834d5
Quick maintainer ping on this ÔÇö happy to open the PR via the web UI if that unblocks it (
CreatePullRequestvia API is blocked on my account for this repo, likely an org policy).I can also extend
assert_remote_manual_compact_request_parityto cover the provider-side paths (env_key,experimental_bearer_token,aws) so we get regression coverage for the cases the current snapshot test in #21676 doesn't exercise. Let me know if you'd like that bundled into the same PR or as a follow-up.For context on impact: confirmed still reproducing on Codex Desktop for Windows
26.513.4821.0(Microsoft Store) against Azure AI Foundry withwire_api = "responses"+env_key, identical config to the repro above.My patches against
0.133.0are at https://github.com/Elefunc/codex/commit/9c37cdf619831eda4c5a11f1e4de6e0c9b207ee4!My patches against
0.134.0are at https://github.com/Elefunc/codex/commit/784669bd7182d4006d57da0cbfe4dc9ebb1bfaf6!My patches against
0.135.0are at https://github.com/Elefunc/codex/commit/47182c23e840a2c57205e75a583312472b98677a!My patches against
0.136.0are at https://github.com/Elefunc/codex/commit/1c6142202bd2147f3bab2bf8e2d65e68340d9e6f!My patches against
0.137.0are at https://github.com/Elefunc/codex/commit/0c0d09d84d4c7a58a6aeb0beb221e52d0a72b335!0.138.0has resolved the issue for me!Closing as resolved in current releases.