From 4b59b83502b9cad18f1dfb58b3754767fd2aa8dc Mon Sep 17 00:00:00 2001 From: rhan-oai Date: Mon, 4 May 2026 15:30:21 -0700 Subject: [PATCH] [codex-analytics] add tool review event schema --- codex-rs/analytics/src/events.rs | 70 ++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/codex-rs/analytics/src/events.rs b/codex-rs/analytics/src/events.rs index dc0e28cdc6..d5c88b9533 100644 --- a/codex-rs/analytics/src/events.rs +++ b/codex-rs/analytics/src/events.rs @@ -75,6 +75,8 @@ pub(crate) enum TrackEventRequest { WebSearch(CodexWebSearchEventRequest), #[allow(dead_code)] ImageGeneration(CodexImageGenerationEventRequest), + #[allow(dead_code)] + ToolCallReview(CodexToolCallReviewEventRequest), PluginUsed(CodexPluginUsedEventRequest), PluginInstalled(CodexPluginEventRequest), PluginUninstalled(CodexPluginEventRequest), @@ -464,6 +466,74 @@ pub(crate) struct CodexToolItemEventBase { pub(crate) retry_count: u64, } +#[allow(dead_code)] +#[derive(Clone, Copy, Debug, Serialize)] +#[serde(rename_all = "snake_case")] +pub(crate) enum ToolReviewToolKind { + CommandExecution, + FileChange, + McpToolCall, + Permissions, + NetworkAccess, +} + +#[allow(dead_code)] +#[derive(Clone, Copy, Debug, Serialize)] +#[serde(rename_all = "snake_case")] +pub(crate) enum ToolReviewReviewer { + Guardian, + User, +} + +#[allow(dead_code)] +#[derive(Clone, Copy, Debug, Serialize)] +#[serde(rename_all = "snake_case")] +pub(crate) enum ToolReviewTrigger { + Initial, + SandboxRetry, + NetworkRetry, + SubcommandExecve, +} + +#[allow(dead_code)] +#[derive(Clone, Copy, Debug, Serialize)] +#[serde(rename_all = "snake_case")] +pub(crate) enum ToolReviewStatus { + Approved, + ApprovedForSession, + ApprovedExecpolicyAmendment, + NetworkPolicyAllow, + NetworkPolicyDeny, + Denied, + Aborted, + TimedOut, +} + +#[derive(Serialize)] +pub(crate) struct CodexToolCallReviewEventParams { + pub(crate) thread_id: String, + pub(crate) turn_id: String, + pub(crate) item_id: Option, + pub(crate) review_id: String, + pub(crate) thread_source: Option<&'static str>, + pub(crate) subagent_source: Option, + pub(crate) parent_thread_id: Option, + pub(crate) tool_kind: ToolReviewToolKind, + pub(crate) tool_name: String, + pub(crate) reviewer: ToolReviewReviewer, + pub(crate) trigger: ToolReviewTrigger, + pub(crate) status: ToolReviewStatus, + pub(crate) created_at: u64, + pub(crate) completed_at: Option, + pub(crate) duration_ms: Option, +} + +#[derive(Serialize)] +pub(crate) struct CodexToolCallReviewEventRequest { + pub(crate) event_type: &'static str, + pub(crate) event_params: CodexToolCallReviewEventParams, +} + #[allow(dead_code)] #[derive(Clone, Copy, Debug, Serialize)] #[serde(rename_all = "snake_case")]