Add logs to model cache (#11551)

This commit is contained in:
Ahmed Ibrahim authored and GitHub committed 2026-02-11 23:25:31 -08:00
1 parent d391f3e2f9
commit 21ceefc0d1
2 files changed
+42 -1

No files matched your search

+13 -1
View File
@@ -26,6 +26,7 @@ use tokio::sync::RwLock;
use tokio::sync::TryLockError;
use tokio::time::timeout;
use tracing::error;
use tracing::info;
const MODEL_CACHE_FILE: &str = "models_cache.json";
const DEFAULT_MODEL_CACHE_TTL: Duration = Duration::from_secs(300);
@@ -216,8 +217,10 @@ impl ModelsManager {
RefreshStrategy::OnlineIfUncached => {
// Try cache first, fall back to online if unavailable
if self.try_load_cache().await {
info!("models cache: using cached models for OnlineIfUncached");
return Ok(());
}
info!("models cache: cache miss, fetching remote models");
self.fetch_and_update_models().await
}
RefreshStrategy::Online => {
@@ -285,13 +288,22 @@ impl ModelsManager {
let _timer =
codex_otel::start_global_timer("codex.remote_models.load_cache.duration_ms", &[]);
let client_version = crate::models_manager::client_version_to_whole();
info!(client_version, "models cache: evaluating cache eligibility");
let cache = match self.cache_manager.load_fresh(&client_version).await {
Some(cache) => cache,
None => return false,
None => {
info!("models cache: no usable cache entry");
return false;
}
};
let models = cache.models.clone();
*self.etag.write().await = cache.etag.clone();
self.apply_remote_models(models.clone()).await;
info!(
models_count = models.len(),
etag = ?cache.etag,
"models cache: cache entry applied"
);
true
}