mirror of
https://github.com/openai/codex.git
synced 2026-11-22 23:00:42 +00:00
Add per-app tool exposure configuration (#46035)
## Why Server-level tool exposure settings apply to every connector on the apps server. Individual connectors need a way to opt out of deferred discovery without changing exposure for other apps. ## What changed Add `apps.<connector_id>.omit_tools_from` with support for `code_mode`, `deferred`, and `direct`. Combine connector omissions with server omissions so app settings preserve server restrictions. For example, `omit_tools_from = ["deferred"]` makes a connector's tools available without tool search, through direct calls or Code Mode as permitted by the active tool mode and remaining restrictions. Expose the setting in the app-server protocol, JSON schemas, and generated TypeScript and Python types. ## Testing Add integration coverage for connector-specific exposure and MCP dispatch across tool modes, server restrictions, and direct-only namespaces. Extend config tests to cover populated, absent, and empty omission lists, and add a Code Mode request-history snapshot. GitOrigin-RevId: cc99ab290c8a878d06d8d7ccf2d1dbd7c46bfa8a
This commit is contained in:
@@ -2341,6 +2341,7 @@ async fn persist_codex_app_tool_approval_writes_tool_override() {
|
||||
"calendar".to_string(),
|
||||
AppConfig {
|
||||
enabled: true,
|
||||
omit_tools_from: None,
|
||||
approvals_reviewer: None,
|
||||
destructive_enabled: None,
|
||||
open_world_enabled: None,
|
||||
|
||||
@@ -61,10 +61,12 @@ use crate::tools::registry::ToolExposure;
|
||||
use crate::tools::registry::ToolRegistry;
|
||||
use crate::tools::router::ToolRouter;
|
||||
use crate::tools::tool_namespaces_info::collect_tool_namespaces_info;
|
||||
use codex_connectors::apps_config_from_layer_stack;
|
||||
use codex_extension_api::ExtensionData;
|
||||
use codex_features::Feature;
|
||||
use codex_features::SleepToolMode;
|
||||
use codex_login::AuthManager;
|
||||
use codex_mcp::CODEX_APPS_MCP_SERVER_NAME;
|
||||
use codex_prompts::ResolvedModelMessages;
|
||||
use codex_protocol::DEFAULT_FUNCTION_NAMESPACE;
|
||||
use codex_protocol::account::PlanType;
|
||||
@@ -195,6 +197,7 @@ fn apply_mcp_tool_exposure_policy(
|
||||
registry: &mut ToolRegistry,
|
||||
) {
|
||||
let mut omitted_exposures_by_tool = HashMap::new();
|
||||
let apps_config = apps_config_from_layer_stack(&turn_context.config.config_layer_stack);
|
||||
for tool in mcp.tools() {
|
||||
let tool_name = tool.canonical_tool_name();
|
||||
if !registered_mcp_tools.contains(&tool_name) {
|
||||
@@ -206,12 +209,19 @@ fn apply_mcp_tool_exposure_policy(
|
||||
omitted_exposures_by_tool
|
||||
.entry(tool_name)
|
||||
.or_insert_with(|| {
|
||||
let connector_omissions = (tool.server_name == CODEX_APPS_MCP_SERVER_NAME)
|
||||
.then_some(tool.connector_id.as_deref())
|
||||
.flatten()
|
||||
.and_then(|id| apps_config.as_ref()?.apps.get(id))
|
||||
.and_then(|app| app.omit_tools_from.as_deref())
|
||||
.unwrap_or_default();
|
||||
server
|
||||
.config()
|
||||
.omit_tools_from
|
||||
.as_deref()
|
||||
.unwrap_or_default()
|
||||
.iter()
|
||||
.chain(connector_omissions)
|
||||
.copied()
|
||||
.collect::<ToolExposures>()
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user