mirror of
https://github.com/openai/codex.git
synced 2026-09-04 15:08:45 +00:00
## 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
48 lines
1.6 KiB
Rust
48 lines
1.6 KiB
Rust
use crate::tools::context::ToolInvocation;
|
|
use crate::tools::context::ToolPayload;
|
|
use crate::tools::flat_tool_name;
|
|
use crate::tools::handlers::unified_exec::ExecCommandArgs;
|
|
use codex_memories_read::usage::MEMORIES_USAGE_METRIC;
|
|
use codex_memories_read::usage::memories_usage_kinds_from_command;
|
|
use codex_protocol::models::ShellCommandToolCallParams;
|
|
|
|
pub(crate) fn emit_metric_for_tool_read(invocation: &ToolInvocation, success: bool) {
|
|
let Some(command) = shell_script_for_invocation(invocation) else {
|
|
return;
|
|
};
|
|
|
|
let success = if success { "true" } else { "false" };
|
|
let tool_name = flat_tool_name(&invocation.tool_name);
|
|
for kind in memories_usage_kinds_from_command(&command) {
|
|
invocation.turn.session_telemetry.counter(
|
|
MEMORIES_USAGE_METRIC,
|
|
/*inc*/ 1,
|
|
&[
|
|
("kind", kind.as_tag()),
|
|
("tool", tool_name.as_ref()),
|
|
("success", success),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
pub(crate) fn shell_script_for_invocation(invocation: &ToolInvocation) -> Option<String> {
|
|
let ToolPayload::Function { arguments } = &invocation.payload else {
|
|
return None;
|
|
};
|
|
|
|
if !invocation.tool_name.is_default_namespace() {
|
|
return None;
|
|
}
|
|
|
|
match invocation.tool_name.name.as_str() {
|
|
"shell_command" => serde_json::from_str::<ShellCommandToolCallParams>(arguments)
|
|
.ok()
|
|
.map(|params| params.command),
|
|
"exec_command" => serde_json::from_str::<ExecCommandArgs>(arguments)
|
|
.ok()
|
|
.map(|params| params.cmd),
|
|
_ => None,
|
|
}
|
|
}
|