Honor thread-level plugin exclusions across runtime capabilities (#44655)

## What changed

- Apply `disabled_plugin_ids` to plugin skills, recommendations, hooks, and MCP servers without modifying shared plugin state.
- Activate selection changes when the next task starts, keeping pending settings from changing the active runtime.
- Hide app tools contributed only by disabled plugins from model tool catalogs and search. Preserve connectors shared with enabled plugins and existing direct Apps RPC behavior.
- Include plugin identity in MCP approval keys and use that identity when persisting plugin tool approvals.

## Testing

Add regression coverage for disabling and re-enabling plugin skills and tools, deferred activation of settings, shared connector ownership, selected plugin servers, executor hooks, and plugin-specific approval keys and persistence.

GitOrigin-RevId: 1153ff6aa7ab6953d50e838da05203904ecd2956
This commit is contained in:
Matthew Zeng authored and copyberry committed 2026-09-10 21:51:34 +00:00
1 parent 5c94936b56
commit 8570091e14
27 files changed
+565 -171

No files matched your search

+54 -7
View File
@@ -1458,13 +1458,21 @@ async fn start_thread_seeds_extension_data_for_mcp_and_lifecycle_contributors()
server.environment_id = environment_id.clone();
server.enabled = false;
let plugin_id = selected_root.id;
vec![codex_extension_api::McpServerContribution::SelectedPlugin {
name: plugin_id.clone(),
plugin_display_name: plugin_id.clone(),
plugin_id,
selection_order: 0,
config: Box::new(server),
}]
vec![
codex_extension_api::McpServerContribution::SelectedPluginPackage {
selected_root_id: plugin_id.clone(),
plugin_id: plugin_id.clone(),
plugin_display_name: plugin_id.clone(),
connector_ids: vec![],
},
codex_extension_api::McpServerContribution::SelectedPlugin {
name: plugin_id.clone(),
plugin_display_name: plugin_id.clone(),
plugin_id,
selection_order: 0,
config: Box::new(server),
},
]
})
}
}
@@ -1477,6 +1485,10 @@ async fn start_thread_seeds_extension_data_for_mcp_and_lifecycle_contributors()
.features
.enable(Feature::Apps)
.expect("test config should allow apps");
config
.features
.enable(Feature::Plugins)
.expect("enable plugins");
std::fs::create_dir_all(&config.codex_home).expect("create codex home");
let lifecycle_observed = Arc::new(std::sync::Mutex::new(Vec::new()));
@@ -1550,6 +1562,7 @@ async fn start_thread_seeds_extension_data_for_mcp_and_lifecycle_contributors()
McpThreadIdentity {
session_source: &SessionSource::Exec,
originator: &first_originator,
disabled_plugin_ids: &[],
environments: McpEnvironmentScope::Live(&first_session.services.turn_environments),
},
/*ready_selected_capability_roots*/ &[],
@@ -1568,6 +1581,7 @@ async fn start_thread_seeds_extension_data_for_mcp_and_lifecycle_contributors()
McpThreadIdentity {
session_source: &second_session_source,
originator: &second_originator,
disabled_plugin_ids: &[],
environments: McpEnvironmentScope::Live(&second_session.services.turn_environments),
},
/*ready_selected_capability_roots*/ &[],
@@ -1628,6 +1642,39 @@ async fn start_thread_seeds_extension_data_for_mcp_and_lifecycle_contributors()
.get("originator"),
Some(&"codex_work_desktop".to_string())
);
for disabled_plugin_ids in [vec!["selected-a".to_string()], vec![]] {
let projection = first_session
.services
.mcp_manager
.runtime_config_for_step(
&config,
&first_session.services.mcp_thread_init,
&first_session.services.thread_extension_data,
McpThreadIdentity {
session_source: &SessionSource::Exec,
originator: &first_originator,
disabled_plugin_ids: &disabled_plugin_ids,
environments: McpEnvironmentScope::Live(
&first_session.services.turn_environments,
),
},
/*ready_selected_capability_roots*/ &[],
/*executor_capability_discovery*/ None,
)
.await;
assert_eq!(
projection.selected_plugins.disabled_plugin_roots,
disabled_plugin_ids
);
assert_eq!(
selected_servers(&projection.config).contains_key("selected-a"),
disabled_plugin_ids.is_empty()
);
assert_eq!(
projection.selected_plugins.plugins.len(),
usize::from(disabled_plugin_ids.is_empty())
);
}
}
#[tokio::test]