mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
Stabilize Guardian client cache key handling (#24891)
Split from the Guardian prompt cache key change. This PR only updates codex-rs/core/src/client.rs. Validation was not run per request; this branch is expected to rely on the companion split PRs.
This commit is contained in:
committed by
GitHub
Unverified
parent
d5ec93f379
commit
c95eb3d07b
@@ -218,6 +218,7 @@ impl RequestRouteTelemetry {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ModelClient {
|
||||
state: Arc<ModelClientState>,
|
||||
prompt_cache_key_override: Option<String>,
|
||||
}
|
||||
|
||||
/// A turn-scoped streaming session created from a [`ModelClient`].
|
||||
@@ -352,9 +353,24 @@ impl ModelClient {
|
||||
disable_websockets: AtomicBool::new(false),
|
||||
cached_websocket_session: StdMutex::new(WebsocketSession::default()),
|
||||
}),
|
||||
prompt_cache_key_override: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn with_prompt_cache_key_override(
|
||||
mut self,
|
||||
prompt_cache_key_override: Option<String>,
|
||||
) -> Self {
|
||||
self.prompt_cache_key_override = prompt_cache_key_override;
|
||||
self
|
||||
}
|
||||
|
||||
fn prompt_cache_key(&self) -> String {
|
||||
self.prompt_cache_key_override
|
||||
.clone()
|
||||
.unwrap_or_else(|| self.state.thread_id.to_string())
|
||||
}
|
||||
|
||||
/// Creates a fresh turn-scoped streaming session.
|
||||
///
|
||||
/// This constructor does not perform network I/O itself; the session opens a websocket lazily
|
||||
@@ -749,7 +765,7 @@ impl ModelClient {
|
||||
&prompt.output_schema,
|
||||
prompt.output_schema_strict,
|
||||
);
|
||||
let prompt_cache_key = Some(self.state.thread_id.to_string());
|
||||
let prompt_cache_key = Some(self.prompt_cache_key());
|
||||
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