Remove ToolName display helper (#21465)

## Why

`ToolName::display()` made it too easy to flatten tool identity and
accidentally compare rendered strings. Tool identity should stay
structural until a legacy string boundary actually requires the
flattened spelling.

## What

- Removes `ToolName::display()` and relies on the existing `Display`
impl for messages and errors.
- Adds structural ordering for `ToolName` and uses it for
sorting/deduping deferred tools.
- Carries `ToolName` through tool/sandbox plumbing, flattening only at
legacy boundaries such as hook payloads, telemetry tags, and Responses
tool names.
- Updates MCP normalization tests to assert `ToolName` structure instead
of rendered strings.

## Testing

- `cargo test -p codex-mcp test_normalize_tools`
- `cargo test -p codex-core unavailable_tool`
- `just fix -p codex-protocol`
- `just fix -p codex-mcp`
- `just fix -p codex-core`
This commit is contained in:
pakrym-oai authored and GitHub committed 2026-05-08 12:17:48 -07:00
1 parent bbb6bf0a37
commit 61142b6169
25 files changed
+123 -71

No files matched your search

+3 -2
View File
@@ -29,6 +29,7 @@ use crate::tools::runtimes::shell::ShellRuntimeBackend;
use crate::tools::sandboxing::ToolCtx;
use codex_protocol::models::AdditionalPermissionProfile;
use codex_protocol::protocol::ExecCommandSource;
use codex_tools::ToolName;
mod container_exec;
mod local_shell;
@@ -72,7 +73,7 @@ fn shell_command_payload_command(payload: &ToolPayload) -> Option<String> {
}
struct RunExecLikeArgs {
tool_name: String,
tool_name: ToolName,
exec_params: ExecParams,
hook_command: String,
additional_permissions: Option<AdditionalPermissionProfile>,
@@ -201,7 +202,7 @@ async fn run_exec_like(args: RunExecLikeArgs) -> Result<FunctionToolOutput, Func
turn.clone(),
Some(&tracker),
&call_id,
tool_name.as_str(),
tool_name.name.as_str(),
)
.await?
{