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
@@ -25,6 +25,7 @@ use crate::tools::registry::AnyToolResult;
|
||||
use crate::tools::registry::ToolArgumentDiffConsumer;
|
||||
use crate::tools::router::ToolCall;
|
||||
use crate::tools::router::ToolCallSource;
|
||||
use codex_history::ResponseItemEnvelope;
|
||||
use codex_protocol::error::CodexErr;
|
||||
use codex_protocol::models::ResponseInputItem;
|
||||
|
||||
@@ -74,7 +75,7 @@ impl ToolCallRuntime {
|
||||
self,
|
||||
call: ToolCall,
|
||||
cancellation_token: CancellationToken,
|
||||
) -> impl std::future::Future<Output = Result<ResponseInputItem, CodexErr>> {
|
||||
) -> impl std::future::Future<Output = Result<ResponseItemEnvelope, CodexErr>> {
|
||||
let error_call = call.clone();
|
||||
let source = call.direct_source();
|
||||
let future = self.handle_tool_call_with_source(call, source, cancellation_token);
|
||||
@@ -82,7 +83,9 @@ impl ToolCallRuntime {
|
||||
match future.await {
|
||||
Ok(response) => Ok(response.into_response()),
|
||||
Err(FunctionCallError::Fatal(message)) => Err(CodexErr::Fatal(message)),
|
||||
Err(other) => Ok(Self::failure_response(error_call, other)),
|
||||
Err(other) => Ok(ResponseItemEnvelope::new(
|
||||
Self::failure_response(error_call, other).into(),
|
||||
)),
|
||||
}
|
||||
}
|
||||
.in_current_span()
|
||||
@@ -655,7 +658,10 @@ mod tests {
|
||||
success: Some(true),
|
||||
},
|
||||
};
|
||||
assert_eq!(expected_response, response);
|
||||
assert_eq!(
|
||||
ResponseItemEnvelope::new(expected_response.into()),
|
||||
response
|
||||
);
|
||||
|
||||
let actual = records
|
||||
.lock()
|
||||
|
||||
Reference in new issue
Block a user