mirror of
https://github.com/openai/codex.git
synced 2026-05-17 09:43:19 +00:00
Omit service_tier from remote /responses/compact requests under API auth (#21676)
## Summary API-key-auth remote compaction requests should not inherit `service_tier` from normal `/responses` turns. This path needs to match API auth expectations, while ChatGPT-auth remote compaction should keep reusing the shared request fields that still apply there. This change keeps the decision inline in `codex-rs/core/src/compact_remote.rs` only. Under API key auth, the classic remote `/responses/compact` path now omits `service_tier`; under ChatGPT auth, it keeps reusing the configured tier. `codex-rs/core/src/compact_remote_v2.rs` is unchanged. The remote compaction parity coverage and snapshots were updated to assert the API-key omission and preserve the ChatGPT-auth behavior. ## Testing - Updated remote compaction parity coverage in `codex-rs/core/tests/suite/compact_remote.rs` and the corresponding snapshots.
This commit is contained in:
@@ -22,6 +22,7 @@ use codex_analytics::CompactionImplementation;
|
||||
use codex_analytics::CompactionPhase;
|
||||
use codex_analytics::CompactionReason;
|
||||
use codex_analytics::CompactionTrigger;
|
||||
use codex_app_server_protocol::AuthMode;
|
||||
use codex_protocol::error::CodexErr;
|
||||
use codex_protocol::error::Result as CodexResult;
|
||||
use codex_protocol::items::ContextCompactionItem;
|
||||
@@ -197,7 +198,11 @@ async fn run_remote_compact_task_inner_impl(
|
||||
CompactConversationRequestSettings {
|
||||
effort: turn_context.reasoning_effort,
|
||||
summary: turn_context.reasoning_summary,
|
||||
service_tier: turn_context.config.service_tier.clone(),
|
||||
service_tier: if sess.services.auth_manager.auth_mode() == Some(AuthMode::ApiKey) {
|
||||
None
|
||||
} else {
|
||||
turn_context.config.service_tier.clone()
|
||||
},
|
||||
},
|
||||
&turn_context.session_telemetry,
|
||||
&compaction_trace,
|
||||
|
||||
@@ -208,7 +208,6 @@ fn should_use_remote_compact_task_for_azure_provider() {
|
||||
|
||||
assert!(should_use_remote_compact_task(&provider));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn process_compacted_history_replaces_developer_messages() {
|
||||
let compacted_history = vec![
|
||||
|
||||
@@ -664,15 +664,16 @@ async fn assert_remote_manual_compact_request_parity(
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn remote_manual_compact_api_auth_reuses_prompt_cache_key() -> Result<()> {
|
||||
async fn remote_manual_compact_api_auth_omits_service_tier_and_reuses_prompt_cache_key()
|
||||
-> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
assert_remote_manual_compact_request_parity(
|
||||
CodexAuth::from_api_key("dummy"),
|
||||
Some(ServiceTier::Fast),
|
||||
Some("priority"),
|
||||
/*expected_service_tier*/ None,
|
||||
"remote_manual_compact_api_auth_prompt_cache_key_request_diff",
|
||||
"After five varied API-key-auth turns, remote manual compaction reuses the normal responses service_tier and prompt_cache_key while omitting responses-only fields.",
|
||||
"After five varied API-key-auth turns, remote manual compaction omits service_tier, reuses prompt_cache_key, and still omits responses-only fields.",
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -689,7 +690,7 @@ async fn remote_manual_compact_chatgpt_auth_reuses_service_tier_and_prompt_cache
|
||||
Some(ServiceTier::Fast),
|
||||
Some("priority"),
|
||||
"remote_manual_compact_chatgpt_auth_service_tier_prompt_cache_key_request_diff",
|
||||
"After five varied ChatGPT-auth turns, remote manual compaction reuses the normal responses service_tier and prompt_cache_key while omitting responses-only fields.",
|
||||
"After five varied ChatGPT-auth turns, remote manual compaction reuses service_tier and prompt_cache_key while omitting responses-only fields.",
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source: core/tests/suite/compact_remote.rs
|
||||
expression: "context_snapshot::format_request_body_diff_snapshot(scenario,\n\"Last Normal /responses Request\", &normal_request,\n\"Remote /responses/compact Request\", &compact_request,\n&ContextSnapshotOptions::default(),)"
|
||||
---
|
||||
Scenario: After five varied API-key-auth turns, remote manual compaction reuses the normal responses service_tier and prompt_cache_key while omitting responses-only fields.
|
||||
Scenario: After five varied API-key-auth turns, remote manual compaction omits service_tier, reuses prompt_cache_key, and still omits responses-only fields.
|
||||
|
||||
--- Last Normal /responses Request
|
||||
+++ Remote /responses/compact Request
|
||||
@@ -38,6 +38,7 @@ Scenario: After five varied API-key-auth turns, remote manual compaction reuses
|
||||
+ ],
|
||||
+ "role": "assistant",
|
||||
+ "type": "message"
|
||||
- "service_tier": "priority",
|
||||
- "store": false,
|
||||
- "stream": true,
|
||||
- "tool_choice": "auto",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
source: core/tests/suite/compact_remote.rs
|
||||
expression: "context_snapshot::format_request_body_diff_snapshot(scenario,\n\"Last Normal /responses Request\", &normal_request,\n\"Remote /responses/compact Request\", &compact_request,\n&ContextSnapshotOptions::default(),)"
|
||||
---
|
||||
Scenario: After five varied ChatGPT-auth turns, remote manual compaction reuses the normal responses service_tier and prompt_cache_key while omitting responses-only fields.
|
||||
Scenario: After five varied ChatGPT-auth turns, remote manual compaction reuses service_tier and prompt_cache_key while omitting responses-only fields.
|
||||
|
||||
--- Last Normal /responses Request
|
||||
+++ Remote /responses/compact Request
|
||||
|
||||
Reference in New Issue
Block a user