mirror of
https://github.com/openai/codex.git
synced 2026-11-25 15:24:26 +00:00
Canonicalize default tools under the functions namespace (#37022)
## What changed - Group top-level function and custom tool definitions into a single `functions` namespace for Responses Lite providers that support namespaced tools. - Normalize missing, empty, and explicit `functions` namespaces to the same tool identity across registration, routing, lifecycle hooks, configuration, and tool search. - Keep default tool names unprefixed in code mode, display output, and dispatch traces while preserving explicit non-default namespaces. ## Testing - Add coverage for Responses Lite serialization, tool search results, namespace normalization and collision handling, routing, lifecycle events, and code-mode namespace policies. GitOrigin-RevId: d48414005b5d22d39b11a198e19c47814d3a19f2
This commit is contained in:
1 parent
1e489adad0
commit
f21dc46388
29 files changed
+522
-78
No files matched your search
@@ -19,6 +19,7 @@ use codex_extension_api::ExtensionRegistryBuilder;
|
||||
use codex_extension_api::ResponsesApiTool;
|
||||
use codex_extension_api::ToolCall as ExtensionToolCall;
|
||||
use codex_extension_api::ToolExecutor;
|
||||
use codex_protocol::DEFAULT_FUNCTION_NAMESPACE;
|
||||
use codex_protocol::dynamic_tools::DynamicToolFunctionSpec;
|
||||
use codex_protocol::dynamic_tools::DynamicToolNamespaceSpec;
|
||||
use codex_protocol::dynamic_tools::DynamicToolNamespaceTool;
|
||||
@@ -268,6 +269,42 @@ async fn build_custom_tool_call_uses_namespace_for_registry_name() -> anyhow::Re
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn build_tool_call_normalizes_default_function_and_custom_namespaces() -> anyhow::Result<()> {
|
||||
for namespace in [None, Some(""), Some(DEFAULT_FUNCTION_NAMESPACE)] {
|
||||
let function_call = ToolRouter::build_tool_call(ResponseItem::FunctionCall {
|
||||
id: None,
|
||||
name: "lookup".to_string(),
|
||||
namespace: namespace.map(str::to_string),
|
||||
arguments: "{}".to_string(),
|
||||
encrypted_function_args: None,
|
||||
call_id: "call-function".to_string(),
|
||||
internal_chat_message_metadata_passthrough: None,
|
||||
})?
|
||||
.expect("function_call should produce a tool call");
|
||||
let custom_call = ToolRouter::build_tool_call(ResponseItem::CustomToolCall {
|
||||
id: None,
|
||||
status: None,
|
||||
call_id: "call-custom".to_string(),
|
||||
name: "apply_patch".to_string(),
|
||||
namespace: namespace.map(str::to_string),
|
||||
input: "patch".to_string(),
|
||||
internal_chat_message_metadata_passthrough: None,
|
||||
})?
|
||||
.expect("custom_tool_call should produce a tool call");
|
||||
|
||||
assert_eq!(
|
||||
[function_call.tool_name, custom_call.tool_name],
|
||||
[
|
||||
ToolName::namespaced(DEFAULT_FUNCTION_NAMESPACE, "lookup"),
|
||||
ToolName::namespaced(DEFAULT_FUNCTION_NAMESPACE, "apply_patch"),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn mcp_parallel_support_uses_handler_data() -> anyhow::Result<()> {
|
||||
let (_, turn) = make_session_and_context().await;
|
||||
|
||||
Reference in new issue
Block a user