mirror of
https://github.com/openai/codex.git
synced 2026-11-17 14:58:36 +00:00
Tag shell tool telemetry by command category (#32887)
## What changed Add a `command_category` tag to tool result telemetry for `exec_command` and `shell_command` invocations. Classify parsed commands as `read`, `list_files`, `search`, or `unknown`; use `mixed` when a script contains multiple categories. GitOrigin-RevId: 1edacb38c7be9b03af4f2fc86746184f19067592
This commit is contained in:
1 parent
bc8222b8d9
commit
bb947e8e36
2 files changed
+21
-2
No files matched your search
@@ -10,6 +10,7 @@ use crate::hook_runtime::record_additional_contexts;
|
||||
use crate::hook_runtime::run_post_tool_use_hooks;
|
||||
use crate::hook_runtime::run_pre_tool_use_hooks;
|
||||
use crate::memory_usage::emit_metric_for_tool_read;
|
||||
use crate::memory_usage::shell_script_for_invocation;
|
||||
use crate::sandbox_tags::permission_profile_policy_tag;
|
||||
use crate::sandbox_tags::permission_profile_sandbox_tag;
|
||||
use crate::session::turn_context::TurnContext;
|
||||
@@ -27,8 +28,10 @@ use crate::util::error_or_panic;
|
||||
use codex_extension_api::ToolCallOutcome;
|
||||
use codex_protocol::models::FunctionCallOutputPayload;
|
||||
use codex_protocol::models::ResponseInputItem;
|
||||
use codex_protocol::parse_command::ParsedCommand;
|
||||
use codex_protocol::protocol::EventMsg;
|
||||
use codex_rollout::state_db;
|
||||
use codex_shell_command::parse_command::parse_shell_script;
|
||||
use codex_tools::ToolName;
|
||||
use codex_tools::ToolSearchInfo;
|
||||
use codex_tools::ToolSpec;
|
||||
@@ -462,7 +465,7 @@ impl ToolRegistry {
|
||||
|
||||
let telemetry_tags = tool.telemetry_tags(&invocation).await;
|
||||
let mut tool_result_tags =
|
||||
Vec::with_capacity(base_tool_result_tags.len() + telemetry_tags.len());
|
||||
Vec::with_capacity(base_tool_result_tags.len() + telemetry_tags.len() + 1);
|
||||
let mut extra_trace_fields = Vec::new();
|
||||
tool_result_tags.extend_from_slice(&base_tool_result_tags);
|
||||
for (key, value) in &telemetry_tags {
|
||||
@@ -538,6 +541,22 @@ impl ToolRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(command) = shell_script_for_invocation(&invocation) {
|
||||
let parsed = parse_shell_script(&command);
|
||||
let mut categories = parsed.iter().map(|command| match command {
|
||||
ParsedCommand::Read { .. } => "read",
|
||||
ParsedCommand::ListFiles { .. } => "list_files",
|
||||
ParsedCommand::Search { .. } => "search",
|
||||
ParsedCommand::Unknown { .. } => "unknown",
|
||||
});
|
||||
let category = match categories.next() {
|
||||
Some(first) if categories.all(|category| category == first) => first,
|
||||
Some(_) => "mixed",
|
||||
None => "unknown",
|
||||
};
|
||||
tool_result_tags.push(("command_category", category));
|
||||
}
|
||||
|
||||
let response_cell = tokio::sync::Mutex::new(None);
|
||||
let invocation_for_tool = invocation.clone();
|
||||
let log_payload = invocation.payload.log_payload();
|
||||
|
||||
Reference in new issue
Block a user