mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +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:
1 parent
03147407e3
commit
f742dabc6f
38 files changed
+487
-224
No files matched your search
@@ -230,8 +230,11 @@ fn mcp_tool_output_response_item_preserves_content_items() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mcp_tool_output_code_mode_result_preserves_content_without_private_metadata() {
|
||||
#[test_case::test_case(TruncationPolicy::Bytes(64); "byte budget")]
|
||||
#[test_case::test_case(TruncationPolicy::Tokens(1); "token budget")]
|
||||
fn mcp_tool_output_code_mode_result_preserves_content_without_private_metadata(
|
||||
truncation_policy: TruncationPolicy,
|
||||
) {
|
||||
let large_content = "large structured value ".repeat(1_000);
|
||||
let output = McpToolOutput {
|
||||
result: CallToolResult {
|
||||
@@ -250,12 +253,13 @@ fn mcp_tool_output_code_mode_result_preserves_content_without_private_metadata()
|
||||
tool_input: json!({}),
|
||||
wall_time: std::time::Duration::from_millis(1250),
|
||||
original_image_detail_supported: false,
|
||||
truncation_policy: TruncationPolicy::Bytes(64),
|
||||
truncation_policy,
|
||||
};
|
||||
|
||||
let result = output.code_mode_result(&ToolPayload::Function {
|
||||
let payload = ToolPayload::Function {
|
||||
arguments: "{}".to_string(),
|
||||
});
|
||||
};
|
||||
let result = output.code_mode_result(&payload);
|
||||
|
||||
assert_eq!(
|
||||
result,
|
||||
|
||||
Reference in new issue
Block a user