mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Preload plugin recommendations during session startup (#41375)
## Why Fetching plugin recommendations while building the first-turn context delays that context when the recommendation catalog is not already cached. ## What changed - Start fetching recommendations during session initialization, in parallel with MCP and plugin setup, and reuse the in-flight request when building context. - Centralize the feature checks that enable plugin recommendations. - Prevent an invalidated recommendation request from repopulating the cache after a newer request has completed. ## Testing Added coverage for startup feature gating, reuse of the in-flight fetch, legacy behavior when recommendations are unavailable, and cache invalidation races. GitOrigin-RevId: 708774b9bfc472c9847973ae8b2774b66e7321e4
This commit is contained in:
@@ -1764,11 +1764,22 @@ impl PluginsManager {
|
||||
.await
|
||||
{
|
||||
Ok(mode) => {
|
||||
let mut cache = match self.recommended_plugins_cache.write() {
|
||||
Ok(cache) => cache,
|
||||
let refreshes = match self.recommended_plugins_refreshes.read() {
|
||||
Ok(refreshes) => refreshes,
|
||||
Err(err) => err.into_inner(),
|
||||
};
|
||||
cache.insert(cache_key.clone(), mode.clone());
|
||||
// Hold the refresh lock through publication, matching cache-clear lock
|
||||
// order. An invalidated initializer must not repopulate the cache.
|
||||
if refreshes
|
||||
.get(&cache_key)
|
||||
.is_some_and(|current| Arc::ptr_eq(current, &refresh))
|
||||
{
|
||||
let mut cache = match self.recommended_plugins_cache.write() {
|
||||
Ok(cache) => cache,
|
||||
Err(err) => err.into_inner(),
|
||||
};
|
||||
cache.insert(cache_key.clone(), mode.clone());
|
||||
}
|
||||
mode
|
||||
}
|
||||
Err(err) => {
|
||||
|
||||
Reference in New Issue
Block a user