mirror of
https://github.com/openai/codex.git
synced 2026-09-07 15:40:00 +00:00
## What changed - Remove the legacy `shell_command` handler and runtime, leaving `exec_command` and `write_stdin` as the shell execution tools. - Treat legacy `shell_command` model metadata as `unified_exec`, and normalize legacy user opt-outs so they do not disable command execution. Managed feature requirements and `shell_tool` can still disable it. - Preserve shell approvals, sandboxing, zsh-fork support, and output truncation through the unified execution path. ## Testing - Cover legacy configuration and model-metadata compatibility. - Exercise unified shell execution, approvals, truncation, and `apply_patch` serialization across the app-server and core test suites. GitOrigin-RevId: 5c2fd6164fc3519cdae4944cb9db276b8467311c
44 lines
1.4 KiB
Rust
44 lines
1.4 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;
|
|
|
|
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() {
|
|
"exec_command" => serde_json::from_str::<ExecCommandArgs>(arguments)
|
|
.ok()
|
|
.map(|params| params.cmd),
|
|
_ => None,
|
|
}
|
|
}
|