Move plugin recommendations into developer context (#47349)

## What changed

Emit `<recommended_plugins>` with the `developer` role and append it to the shared developer message after other context. Retain recognition of legacy user-role recommendations in existing rollouts.

## Testing

Add a startup context snapshot and assertions that recommendations share the developer message with permissions instructions. Update core and app-server tests to check developer-role recommendations, including across successive model requests.

GitOrigin-RevId: 0326ff347e86ec38b948f93e39e90e6a88a8730c
This commit is contained in:
Alex Daley
2026-09-22 19:51:33 +00:00
committed by copyberry
parent 5121aeff13
commit 9124e23e2c
7 changed files with 111 additions and 22 deletions
@@ -27,6 +27,7 @@ const CONTEXTUAL_USER_FRAGMENT_MATCHERS: &[fn(&str) -> bool] = &[
TurnAborted::matches_text,
SubagentNotification::matches_text,
InternalModelContextFragment::matches_text,
// compatibility for user-role recommendation messages in existing rollouts
RecommendedPluginsInstructions::matches_text,
LegacyUnifiedExecProcessLimitWarning::matches_text,
LegacyApplyPatchExecCommandWarning::matches_text,
@@ -32,7 +32,7 @@ impl ContextualUserFragment for RecommendedPluginsInstructions {
}
fn role(&self) -> &'static str {
"user"
"developer"
}
fn markers(&self) -> (&'static str, &'static str) {
+7 -6
View File
@@ -4226,12 +4226,6 @@ impl Session {
} else {
None
};
if let Some(recommended_plugins) = recommended_plugin_candidates
.as_deref()
.and_then(RecommendedPluginsInstructions::from_plugins)
{
contextual_user_sections.push(recommended_plugins.render_fragment());
}
let context_contributors = self.services.extensions.context_contributors().to_vec();
for contributor in &context_contributors {
for fragment in contributor
@@ -4360,6 +4354,13 @@ impl Session {
}
}
if let Some(recommended_plugins) = recommended_plugin_candidates
.as_deref()
.and_then(RecommendedPluginsInstructions::from_plugins)
{
developer_sections.push(recommended_plugins.render_fragment());
}
let mut items = Vec::with_capacity(4);
if let Some(developer_message) =
crate::context_manager::updates::build_rendered_message(developer_sections)
+4 -1
View File
@@ -9986,7 +9986,10 @@ async fn build_initial_context_reuses_in_flight_recommendation_prewarm() {
let (_, initial_context) = tokio::join!(prewarm, initial_context);
assert_eq!(
user_input_texts(&initial_context),
developer_input_texts(&initial_context)
.into_iter()
.filter(|text| text.starts_with("<recommended_plugins>"))
.collect::<Vec<_>>(),
vec![concat!(
"<recommended_plugins>\n",
"Here is a list of plugins that are available but not installed.\n\n",