mirror of
https://github.com/openai/codex.git
synced 2026-04-30 01:16:54 +00:00
chore: drop mcp validation of dynamic tools (#11609)
Drop validation of dynamic tools using MCP names to reduce latency
This commit is contained in:
@@ -1910,9 +1910,7 @@ impl CodexMessageProcessor {
|
||||
let core_dynamic_tools = if dynamic_tools.is_empty() {
|
||||
Vec::new()
|
||||
} else {
|
||||
let snapshot = collect_mcp_snapshot(&config).await;
|
||||
let mcp_tool_names = snapshot.tools.keys().cloned().collect::<HashSet<_>>();
|
||||
if let Err(message) = validate_dynamic_tools(&dynamic_tools, &mcp_tool_names) {
|
||||
if let Err(message) = validate_dynamic_tools(&dynamic_tools) {
|
||||
let error = JSONRPCErrorError {
|
||||
code: INVALID_REQUEST_ERROR_CODE,
|
||||
message,
|
||||
@@ -5712,10 +5710,7 @@ fn errors_to_info(
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn validate_dynamic_tools(
|
||||
tools: &[ApiDynamicToolSpec],
|
||||
mcp_tool_names: &HashSet<String>,
|
||||
) -> Result<(), String> {
|
||||
fn validate_dynamic_tools(tools: &[ApiDynamicToolSpec]) -> Result<(), String> {
|
||||
let mut seen = HashSet::new();
|
||||
for tool in tools {
|
||||
let name = tool.name.trim();
|
||||
@@ -5731,9 +5726,6 @@ fn validate_dynamic_tools(
|
||||
if name == "mcp" || name.starts_with("mcp__") {
|
||||
return Err(format!("dynamic tool name is reserved: {name}"));
|
||||
}
|
||||
if mcp_tool_names.contains(name) {
|
||||
return Err(format!("dynamic tool name conflicts with MCP tool: {name}"));
|
||||
}
|
||||
if !seen.insert(name.to_string()) {
|
||||
return Err(format!("duplicate dynamic tool name: {name}"));
|
||||
}
|
||||
@@ -6236,7 +6228,7 @@ mod tests {
|
||||
description: "test".to_string(),
|
||||
input_schema: json!({"type": "null"}),
|
||||
}];
|
||||
let err = validate_dynamic_tools(&tools, &HashSet::new()).expect_err("invalid schema");
|
||||
let err = validate_dynamic_tools(&tools).expect_err("invalid schema");
|
||||
assert!(err.contains("my_tool"), "unexpected error: {err}");
|
||||
}
|
||||
|
||||
@@ -6248,7 +6240,7 @@ mod tests {
|
||||
// Missing `type` is common; core sanitizes these to a supported schema.
|
||||
input_schema: json!({"properties": {}}),
|
||||
}];
|
||||
validate_dynamic_tools(&tools, &HashSet::new()).expect("valid schema");
|
||||
validate_dynamic_tools(&tools).expect("valid schema");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user