Search selected plugin apps before falling back (#38484)

## What changed

- When an explicitly selected plugin has apps available, instruct the model to use `tool_search` to discover relevant tools before falling back to unrelated or built-in tools.
- Scope the guidance to the request that selected the plugin and omit it for plugins without available apps.

## Testing

- Cover app-specific rendering, non-app plugins, bounded instruction output, and app enablement in dual-surface plugin requests.

GitOrigin-RevId: 1b9501cc403d2817334a9307e683e99c140a794a
This commit is contained in:
dozaki-openai
2026-08-14 02:54:38 +00:00
committed by copyberry
parent 9d012ca4f5
commit cbe85e117b
3 changed files with 63 additions and 12 deletions
+22 -11
View File
@@ -24,6 +24,17 @@ pub(crate) fn render_explicit_plugin_instructions(
plugin.display_name
)];
if !available_apps.is_empty() {
lines.push(
concat!(
"- For the user request that explicitly selected this plugin, and only for that ",
"request, if `tool_search` is available and an app from this plugin may help, ",
"search for its tools before falling back to unrelated or built-in tools."
)
.to_string(),
);
}
if plugin.has_skills {
let skill_namespace = plugin
.plugin_namespace
@@ -34,17 +45,6 @@ pub(crate) fn render_explicit_plugin_instructions(
));
}
if !available_mcp_servers.is_empty() {
lines.push(format!(
"- MCP servers from this plugin available in this session: {}.",
available_mcp_servers
.iter()
.map(|server| format!("`{server}`"))
.collect::<Vec<_>>()
.join(", ")
));
}
if !available_apps.is_empty() {
lines.push(format!(
"- Apps from this plugin available in this session: {}.",
@@ -56,6 +56,17 @@ pub(crate) fn render_explicit_plugin_instructions(
));
}
if !available_mcp_servers.is_empty() {
lines.push(format!(
"- MCP servers from this plugin available in this session: {}.",
available_mcp_servers
.iter()
.map(|server| format!("`{server}`"))
.collect::<Vec<_>>()
.join(", ")
));
}
if lines.len() == 1 {
return None;
}