mirror of
https://github.com/openai/codex.git
synced 2026-10-29 00:06:55 +00:00
Use session IDs for prompt cache keys (#33035)
## What changed - Default `prompt_cache_key` to the session ID from response metadata instead of the thread ID. - Preserve explicit prompt cache key overrides. - Verify that API-key-authenticated root and subagent requests use the same session-based cache key even though they have different thread IDs. GitOrigin-RevId: cb1bf21a3cb8fa2c5083c5c6afd4829ff2adcf1f
This commit is contained in:
@@ -466,10 +466,10 @@ impl ModelClient {
|
||||
self
|
||||
}
|
||||
|
||||
fn prompt_cache_key(&self) -> String {
|
||||
fn prompt_cache_key(&self, responses_metadata: &CodexResponsesMetadata) -> String {
|
||||
self.prompt_cache_key_override
|
||||
.clone()
|
||||
.unwrap_or_else(|| self.state.thread_id.to_string())
|
||||
.unwrap_or_else(|| responses_metadata.session_id.clone())
|
||||
}
|
||||
|
||||
/// Creates a fresh turn-scoped streaming session.
|
||||
@@ -885,7 +885,7 @@ impl ModelClient {
|
||||
&prompt.output_schema,
|
||||
prompt.output_schema_strict,
|
||||
);
|
||||
let prompt_cache_key = Some(self.prompt_cache_key());
|
||||
let prompt_cache_key = Some(self.prompt_cache_key(responses_metadata));
|
||||
let service_tier = model_info.service_tier_for_request(service_tier);
|
||||
let request = ResponsesApiRequest {
|
||||
model: model_info.slug.clone(),
|
||||
|
||||
Reference in New Issue
Block a user