mirror of
https://github.com/openai/codex.git
synced 2026-10-29 19:08:43 +00:00
Support per-tool MCP output limits (#41421)
## What changed - Add a positive `output_token_limit` setting to each entry under an MCP server's `tools` configuration. - Apply the most restrictive limit when plugin and user policies overlap, while keeping approval policy independent. - Carry the effective MCP output budget in conversation history so tool output, post-tool hook responses, and resumed sessions use the same truncation limit. ## Testing - Cover configuration parsing, serialization, schema validation, and plugin policy merging. - Cover MCP output below and above the configured limit, post-tool hook responses, and session resume. GitOrigin-RevId: d0beb4fca9ba6055d9e1d31c137373b465d50d61
This commit is contained in:
@@ -974,6 +974,7 @@ fn apply_plugin_mcp_server_policy(config: &mut McpServerConfig, policy: &PluginM
|
||||
if let Some(approval_mode) = tool_policy.approval_mode {
|
||||
tool_config.approval_mode = Some(approval_mode);
|
||||
}
|
||||
tool_config.restrict_output_token_limit(tool_policy.output_token_limit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1449,7 +1450,7 @@ pub fn apply_configured_plugin_mcp_server_policies(
|
||||
}
|
||||
}
|
||||
for (tool_name, tool_policy) in &policy.tools {
|
||||
if tool_policy.approval_mode.is_some() {
|
||||
if tool_policy.approval_mode.is_some() || tool_policy.output_token_limit.is_some() {
|
||||
server.tools.entry(tool_name.clone()).or_default();
|
||||
}
|
||||
}
|
||||
@@ -1467,6 +1468,12 @@ pub fn apply_configured_plugin_mcp_server_policies(
|
||||
.restrict_to(approval_mode),
|
||||
);
|
||||
}
|
||||
tool_config.restrict_output_token_limit(
|
||||
policy
|
||||
.tools
|
||||
.get(tool_name)
|
||||
.and_then(|tool_policy| tool_policy.output_token_limit),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user