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:
Matthew Zeng authored and copyberry committed 2026-08-28 17:33:10 +00:00
1 parent 5ed294d49d
commit 8bcac28f93
7 files changed
+391 -14

No files matched your search

+4 -5
View File
@@ -3731,11 +3731,10 @@ impl Session {
.plugins_manager
.plugins_for_config(&turn_context.config.plugins_config_input())
.await;
let features = turn_context.config.features.get();
let recommended_plugin_candidates = if features.enabled(Feature::Apps)
&& features.enabled(Feature::Plugins)
&& (features.enabled(Feature::ToolSuggest)
|| features.enabled(Feature::RecommendedPlugins))
let recommended_plugin_candidates = if turn_context
.config
.features
.plugin_recommendations_enabled()
{
let auth = self.services.auth_manager.auth().await;
let plugins_config = turn_context.config.plugins_config_input();