mirror of
https://github.com/openai/codex.git
synced 2026-05-28 06:55:01 +00:00
Remove reserved namespaces dedup (#24609)
Avoid suffixing reserved namespaces.
This commit is contained in:
@@ -415,45 +415,6 @@ fn test_normalize_tools_keeps_hyphenated_mcp_tools_callable() {
|
||||
assert_eq!(tool.tool.name, "get-strudel-guide");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_normalize_tools_disambiguates_reserved_unprefixed_namespaces() {
|
||||
let tools = vec![
|
||||
create_test_tool("tools", "list"),
|
||||
create_test_tool("web", "search"),
|
||||
];
|
||||
|
||||
let model_tools =
|
||||
normalize_tools_for_model_with_prefix(tools, /*prefix_mcp_tool_names*/ false);
|
||||
|
||||
assert_eq!(model_tools.len(), 2);
|
||||
let namespaces = model_tools
|
||||
.iter()
|
||||
.map(|tool| tool.callable_namespace.as_str())
|
||||
.collect::<HashSet<_>>();
|
||||
assert_eq!(namespaces.len(), 2);
|
||||
assert!(
|
||||
namespaces
|
||||
.iter()
|
||||
.all(|namespace| !matches!(*namespace, "tools" | "web")),
|
||||
"reserved namespaces should be disambiguated: {namespaces:?}"
|
||||
);
|
||||
assert!(
|
||||
namespaces
|
||||
.iter()
|
||||
.any(|namespace| namespace.starts_with("tools_"))
|
||||
);
|
||||
assert!(
|
||||
namespaces
|
||||
.iter()
|
||||
.any(|namespace| namespace.starts_with("web_"))
|
||||
);
|
||||
let model_names = model_tool_names(&model_tools);
|
||||
assert!(
|
||||
model_names.iter().all(is_code_mode_compatible_tool_name),
|
||||
"model-visible names must be code-mode compatible: {model_names:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_normalize_tools_disambiguates_sanitized_namespace_collisions() {
|
||||
let tools = vec![
|
||||
|
||||
@@ -171,16 +171,10 @@ where
|
||||
continue;
|
||||
}
|
||||
|
||||
let mut callable_namespace = callable_namespace_with_prefix(
|
||||
let callable_namespace = callable_namespace_with_prefix(
|
||||
&sanitize_responses_api_tool_name(&tool.callable_namespace),
|
||||
prefix_mcp_tool_names,
|
||||
);
|
||||
if !prefix_mcp_tool_names
|
||||
&& RESERVED_UNPREFIXED_MCP_NAMESPACES.contains(&callable_namespace.as_str())
|
||||
{
|
||||
callable_namespace =
|
||||
append_namespace_hash_suffix(&callable_namespace, &raw_namespace_identity);
|
||||
}
|
||||
|
||||
candidates.push(CallableToolCandidate {
|
||||
callable_namespace,
|
||||
@@ -267,7 +261,6 @@ const MCP_TOOL_NAME_DELIMITER: &str = "__";
|
||||
const MAX_TOOL_NAME_LENGTH: usize = 64;
|
||||
const CALLABLE_NAME_HASH_LEN: usize = 12;
|
||||
const META_OPENAI_FILE_PARAMS: &str = "openai/fileParams";
|
||||
const RESERVED_UNPREFIXED_MCP_NAMESPACES: &[&str] = &["tools", "web"];
|
||||
|
||||
fn callable_namespace_with_prefix(namespace: &str, prefix_mcp_tool_names: bool) -> String {
|
||||
if !prefix_mcp_tool_names || namespace.starts_with(LEGACY_MCP_TOOL_NAME_PREFIX) {
|
||||
|
||||
Reference in New Issue
Block a user