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:
ptiet-oai
2026-09-16 21:50:07 +00:00
committed by copyberry
parent 29e6bc814e
commit a6d4741d39
20 changed files with 465 additions and 2 deletions
@@ -7094,6 +7094,16 @@
],
"description": "Per-account approval settings keyed by link ID."
},
"omit_tools_from": {
"description": "Additional model-facing surfaces omitted for this connector's tools.",
"items": {
"$ref": "#/definitions/v2/ToolExposureSurface"
},
"type": [
"array",
"null"
]
},
"open_world_enabled": {
"type": [
"boolean",
@@ -24873,6 +24883,32 @@
],
"type": "object"
},
"ToolExposureSurface": {
"description": "A model-facing surface on which a tool can be exposed.",
"oneOf": [
{
"description": "Nested tools available to Code Mode scripts.",
"enum": [
"code_mode"
],
"type": "string"
},
{
"description": "Tools discovered later through tool search.",
"enum": [
"deferred"
],
"type": "string"
},
{
"description": "Tools present in the model's initial tool list.",
"enum": [
"direct"
],
"type": "string"
}
]
},
"ToolsV2": {
"properties": {
"web_search": {
@@ -510,6 +510,16 @@
],
"description": "Per-account approval settings keyed by link ID."
},
"omit_tools_from": {
"description": "Additional model-facing surfaces omitted for this connector's tools.",
"items": {
"$ref": "#/definitions/ToolExposureSurface"
},
"type": [
"array",
"null"
]
},
"open_world_enabled": {
"type": [
"boolean",
@@ -22587,6 +22597,32 @@
],
"type": "object"
},
"ToolExposureSurface": {
"description": "A model-facing surface on which a tool can be exposed.",
"oneOf": [
{
"description": "Nested tools available to Code Mode scripts.",
"enum": [
"code_mode"
],
"type": "string"
},
{
"description": "Tools discovered later through tool search.",
"enum": [
"deferred"
],
"type": "string"
},
{
"description": "Tools present in the model's initial tool list.",
"enum": [
"direct"
],
"type": "string"
}
]
},
"ToolsV2": {
"properties": {
"web_search": {
@@ -73,6 +73,16 @@
],
"description": "Per-account approval settings keyed by link ID."
},
"omit_tools_from": {
"description": "Additional model-facing surfaces omitted for this connector's tools.",
"items": {
"$ref": "#/definitions/ToolExposureSurface"
},
"type": [
"array",
"null"
]
},
"open_world_enabled": {
"type": [
"boolean",
@@ -1009,6 +1019,32 @@
},
"type": "object"
},
"ToolExposureSurface": {
"description": "A model-facing surface on which a tool can be exposed.",
"oneOf": [
{
"description": "Nested tools available to Code Mode scripts.",
"enum": [
"code_mode"
],
"type": "string"
},
{
"description": "Tools discovered later through tool search.",
"enum": [
"deferred"
],
"type": "string"
},
{
"description": "Tools present in the model's initial tool list.",
"enum": [
"direct"
],
"type": "string"
}
]
},
"ToolsV2": {
"properties": {
"web_search": {
@@ -0,0 +1,8 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
/**
* A model-facing surface on which a tool can be exposed.
*/
export type ToolExposureSurface = "code_mode" | "deferred" | "direct";
+1
View File
@@ -85,6 +85,7 @@ export type { SubAgentSource } from "./SubAgentSource";
export type { ThreadId } from "./ThreadId";
export type { ThreadMemoryMode } from "./ThreadMemoryMode";
export type { Tool } from "./Tool";
export type { ToolExposureSurface } from "./ToolExposureSurface";
export type { Verbosity } from "./Verbosity";
export type { WebSearchAction } from "./WebSearchAction";
export type { WebSearchContextSize } from "./WebSearchContextSize";
@@ -1,13 +1,18 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { ToolExposureSurface } from "../ToolExposureSurface";
import type { AppLinksConfig } from "./AppLinksConfig";
import type { AppToolApproval } from "./AppToolApproval";
import type { AppToolsConfig } from "./AppToolsConfig";
import type { ApprovalsReviewer } from "./ApprovalsReviewer";
import type { AppsDefaultConfig } from "./AppsDefaultConfig";
export type AppsConfig = { _default: AppsDefaultConfig | null, } & ({ [key in string]?: { enabled: boolean, approvals_reviewer: ApprovalsReviewer | null, destructive_enabled: boolean | null, open_world_enabled: boolean | null, default_tools_approval_mode: AppToolApproval | null, default_tools_enabled: boolean | null, tools: AppToolsConfig | null,
export type AppsConfig = { _default: AppsDefaultConfig | null, } & ({ [key in string]?: { enabled: boolean,
/**
* Additional model-facing surfaces omitted for this connector's tools.
*/
omit_tools_from: Array<ToolExposureSurface> | null, approvals_reviewer: ApprovalsReviewer | null, destructive_enabled: boolean | null, open_world_enabled: boolean | null, default_tools_approval_mode: AppToolApproval | null, default_tools_enabled: boolean | null, tools: AppToolsConfig | null,
/**
* Per-account approval settings keyed by link ID.
*/
@@ -12,6 +12,7 @@ use codex_experimental_api_macros::ExperimentalApi;
use codex_protocol::config_types::AutoCompactTokenLimitScope;
use codex_protocol::config_types::ForcedLoginMethod;
use codex_protocol::config_types::ReasoningSummary;
use codex_protocol::config_types::ToolExposureSurface;
use codex_protocol::config_types::Verbosity;
use codex_protocol::config_types::WebSearchMode;
use codex_protocol::config_types::WebSearchToolConfig;
@@ -234,6 +235,8 @@ pub struct AppLinksConfig {
pub struct AppConfig {
#[serde(default = "default_enabled")]
pub enabled: bool,
/// Additional model-facing surfaces omitted for this connector's tools.
pub omit_tools_from: Option<Vec<ToolExposureSurface>>,
pub approvals_reviewer: Option<ApprovalsReviewer>,
pub destructive_enabled: Option<bool>,
pub open_world_enabled: Option<bool>,