Lightweight coding agent that runs in your terminal
Rust
[codex-analytics] add tool review event schema (#18747)
rhan-oai3444b0d60ac8
diff --git a/codex-rs/analytics/src/analytics_client_tests.rs b/codex-rs/analytics/src/analytics_client_tests.rsindex fd294385e5..880adfc254 100644--- a/codex-rs/analytics/src/analytics_client_tests.rs+++ b/codex-rs/analytics/src/analytics_client_tests.rs@@ -1012,7 +1012,7 @@ fn command_execution_event_serializes_expected_shape() {runtime_os_version: "15.3.1".to_string(),runtime_arch: "aarch64".to_string(),},- thread_source: Some("user"),+ thread_source: Some(ThreadSource::User),subagent_source: None,parent_thread_id: None,tool_name: "shell".to_string(),diff --git a/codex-rs/analytics/src/events.rs b/codex-rs/analytics/src/events.rsindex 2bcd43f380..23afd83b75 100644--- a/codex-rs/analytics/src/events.rs+++ b/codex-rs/analytics/src/events.rs@@ -70,6 +70,8 @@ pub(crate) enum TrackEventRequest {CollabAgentToolCall(CodexCollabAgentToolCallEventRequest),WebSearch(CodexWebSearchEventRequest),ImageGeneration(CodexImageGenerationEventRequest),+ #[allow(dead_code)]+ ReviewEvent(CodexReviewEventRequest),PluginUsed(CodexPluginUsedEventRequest),PluginInstalled(CodexPluginEventRequest),PluginUninstalled(CodexPluginEventRequest),@@ -442,7 +444,7 @@ pub(crate) struct CodexToolItemEventBase {pub(crate) item_id: String,pub(crate) app_server_client: CodexAppServerClientMetadata,pub(crate) runtime: CodexRuntimeMetadata,- pub(crate) thread_source: Option<&'static str>,+ pub(crate) thread_source: Option<ThreadSource>,pub(crate) subagent_source: Option<String>,pub(crate) parent_thread_id: Option<String>,pub(crate) tool_name: String,@@ -462,6 +464,83 @@ pub(crate) struct CodexToolItemEventBase {pub(crate) requested_network_access: bool,}+#[allow(dead_code)]+#[derive(Clone, Copy, Debug, Serialize)]+#[serde(rename_all = "snake_case")]+pub(crate) enum ReviewSubjectKind {+ CommandExecution,+ FileChange,+ McpToolCall,+ Permissions,+ NetworkAccess,+}++#[allow(dead_code)]+#[derive(Clone, Copy, Debug, Serialize)]+#[serde(rename_all = "snake_case")]+pub(crate) enum Reviewer {+ Guardian,+ User,+}++#[allow(dead_code)]+#[derive(Clone, Copy, Debug, Serialize)]+#[serde(rename_all = "snake_case")]+pub(crate) enum ReviewTrigger {+ Initial,+ SandboxDenial,+ NetworkPolicyDenial,+ ExecveIntercept,+}++#[allow(dead_code)]+#[derive(Clone, Copy, Debug, Serialize)]+#[serde(rename_all = "snake_case")]+pub(crate) enum ReviewStatus {+ Approved,+ Denied,+ Aborted,+ TimedOut,+}++#[allow(dead_code)]+#[derive(Clone, Copy, Debug, Serialize)]+#[serde(rename_all = "snake_case")]+pub(crate) enum ReviewResolution {+ None,+ SessionApproval,+ ExecPolicyAmendment,+ NetworkPolicyAmendment,+}++#[derive(Serialize)]+pub(crate) struct CodexReviewEventParams {+ pub(crate) thread_id: String,+ pub(crate) turn_id: String,+ pub(crate) item_id: Option<String>,+ pub(crate) review_id: String,+ pub(crate) app_server_client: CodexAppServerClientMetadata,+ pub(crate) runtime: CodexRuntimeMetadata,+ pub(crate) thread_source: Option<ThreadSource>,+ pub(crate) subagent_source: Option<String>,+ pub(crate) parent_thread_id: Option<String>,+ pub(crate) tool_kind: ReviewSubjectKind,+ pub(crate) tool_name: String,+ pub(crate) reviewer: Reviewer,+ pub(crate) trigger: ReviewTrigger,+ pub(crate) status: ReviewStatus,+ pub(crate) resolution: ReviewResolution,+ pub(crate) started_at_ms: u64,+ pub(crate) completed_at_ms: u64,+ pub(crate) duration_ms: Option<u64>,+}++#[derive(Serialize)]+pub(crate) struct CodexReviewEventRequest {+ pub(crate) event_type: &'static str,+ pub(crate) event_params: CodexReviewEventParams,+}+#[allow(dead_code)]#[derive(Clone, Copy, Debug, Serialize)]#[serde(rename_all = "snake_case")]pub(crate) enum WebSearchActionKind {diff --git a/codex-rs/analytics/src/reducer.rs b/codex-rs/analytics/src/reducer.rsindex 81530444de..d35fb96602 100644--- a/codex-rs/analytics/src/reducer.rs+++ b/codex-rs/analytics/src/reducer.rs@@ -1447,7 +1447,7 @@ fn tool_item_base(item_id,app_server_client: context.connection_state.app_server_client.clone(),runtime: context.connection_state.runtime.clone(),- thread_source: thread_metadata.thread_source.map(ThreadSource::as_str),+ thread_source: thread_metadata.thread_source,subagent_source: thread_metadata.subagent_source.clone(),parent_thread_id: thread_metadata.parent_thread_id.clone(),tool_name,