-
Notifications
You must be signed in to change notification settings - Fork 11.6k
[codex-analytics] add tool item event schemas #17089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,20 @@ pub(crate) enum TrackEventRequest { | |
| Compaction(Box<CodexCompactionEventRequest>), | ||
| TurnEvent(Box<CodexTurnEventRequest>), | ||
| TurnSteer(CodexTurnSteerEventRequest), | ||
| #[allow(dead_code)] | ||
| CommandExecution(CodexCommandExecutionEventRequest), | ||
| #[allow(dead_code)] | ||
| FileChange(CodexFileChangeEventRequest), | ||
| #[allow(dead_code)] | ||
| McpToolCall(CodexMcpToolCallEventRequest), | ||
| #[allow(dead_code)] | ||
| DynamicToolCall(CodexDynamicToolCallEventRequest), | ||
| #[allow(dead_code)] | ||
| CollabAgentToolCall(CodexCollabAgentToolCallEventRequest), | ||
| #[allow(dead_code)] | ||
| WebSearch(CodexWebSearchEventRequest), | ||
| #[allow(dead_code)] | ||
| ImageGeneration(CodexImageGenerationEventRequest), | ||
| PluginUsed(CodexPluginUsedEventRequest), | ||
| PluginInstalled(CodexPluginEventRequest), | ||
| PluginUninstalled(CodexPluginEventRequest), | ||
|
|
@@ -384,6 +398,208 @@ pub(crate) struct GuardianReviewEventPayload { | |
| pub(crate) guardian_review: GuardianReviewEventParams, | ||
| } | ||
|
|
||
| #[allow(dead_code)] | ||
| #[derive(Clone, Copy, Debug, Serialize)] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub(crate) enum ToolItemFinalApprovalOutcome { | ||
| Unknown, | ||
| NotNeeded, | ||
| ConfigAllowed, | ||
| PolicyForbidden, | ||
| GuardianApproved, | ||
| GuardianDenied, | ||
| GuardianAborted, | ||
| UserApproved, | ||
| UserApprovedForSession, | ||
| UserDenied, | ||
| UserAborted, | ||
| } | ||
|
|
||
| #[allow(dead_code)] | ||
| #[derive(Clone, Copy, Debug, Serialize)] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub(crate) enum ToolItemTerminalStatus { | ||
| Completed, | ||
| Failed, | ||
| Rejected, | ||
| Interrupted, | ||
| } | ||
|
|
||
| #[allow(dead_code)] | ||
| #[derive(Clone, Copy, Debug, Serialize)] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub(crate) enum ToolItemFailureKind { | ||
| ToolError, | ||
| ApprovalDenied, | ||
| ApprovalAborted, | ||
| SandboxDenied, | ||
| PolicyForbidden, | ||
| } | ||
|
|
||
| #[derive(Serialize)] | ||
| pub(crate) struct CodexToolItemEventBase { | ||
| pub(crate) thread_id: String, | ||
| pub(crate) turn_id: String, | ||
| /// App-server ThreadItem.id. For tool-originated items this generally | ||
| /// corresponds to the originating core call_id. | ||
| pub(crate) item_id: String, | ||
| pub(crate) app_server_client: CodexAppServerClientMetadata, | ||
| pub(crate) runtime: CodexRuntimeMetadata, | ||
| pub(crate) thread_source: Option<&'static str>, | ||
| pub(crate) subagent_source: Option<String>, | ||
| pub(crate) parent_thread_id: Option<String>, | ||
| pub(crate) tool_name: String, | ||
| pub(crate) started_at_ms: u64, | ||
| pub(crate) completed_at_ms: u64, | ||
| pub(crate) duration_ms: Option<u64>, | ||
| pub(crate) review_count: u64, | ||
| pub(crate) guardian_review_count: u64, | ||
| pub(crate) user_review_count: u64, | ||
| pub(crate) final_approval_outcome: ToolItemFinalApprovalOutcome, | ||
| pub(crate) terminal_status: ToolItemTerminalStatus, | ||
| pub(crate) failure_kind: Option<ToolItemFailureKind>, | ||
| pub(crate) requested_additional_permissions: bool, | ||
| pub(crate) requested_network_access: bool, | ||
| } | ||
|
|
||
| #[allow(dead_code)] | ||
| #[derive(Clone, Copy, Debug, Serialize)] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub(crate) enum CommandExecutionSource { | ||
| Agent, | ||
| UserShell, | ||
| UnifiedExecStartup, | ||
| UnifiedExecInteraction, | ||
| } | ||
|
|
||
| #[allow(dead_code)] | ||
| #[derive(Clone, Copy, Debug, Serialize)] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub(crate) enum WebSearchActionKind { | ||
| Search, | ||
| OpenPage, | ||
| FindInPage, | ||
| Other, | ||
| } | ||
|
|
||
| #[derive(Serialize)] | ||
| pub(crate) struct CodexCommandExecutionEventParams { | ||
| #[serde(flatten)] | ||
| pub(crate) base: CodexToolItemEventBase, | ||
| pub(crate) command_execution_source: CommandExecutionSource, | ||
| pub(crate) exit_code: Option<i32>, | ||
| pub(crate) command_total_action_count: u64, | ||
| pub(crate) command_read_action_count: u64, | ||
| pub(crate) command_list_files_action_count: u64, | ||
| pub(crate) command_search_action_count: u64, | ||
| pub(crate) command_unknown_action_count: u64, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, how are all these
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i mean, technically we can, but would it be brittle and hard to maintain?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or do we already have existing code doing this?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes we do, parsed as command actions: |
||
| } | ||
|
|
||
| #[derive(Serialize)] | ||
| pub(crate) struct CodexCommandExecutionEventRequest { | ||
| pub(crate) event_type: &'static str, | ||
| pub(crate) event_params: CodexCommandExecutionEventParams, | ||
| } | ||
|
|
||
| #[derive(Serialize)] | ||
| pub(crate) struct CodexFileChangeEventParams { | ||
| #[serde(flatten)] | ||
| pub(crate) base: CodexToolItemEventBase, | ||
| pub(crate) file_change_count: u64, | ||
| pub(crate) file_add_count: u64, | ||
| pub(crate) file_update_count: u64, | ||
| pub(crate) file_delete_count: u64, | ||
| pub(crate) file_move_count: u64, | ||
| } | ||
|
|
||
| #[derive(Serialize)] | ||
| pub(crate) struct CodexFileChangeEventRequest { | ||
| pub(crate) event_type: &'static str, | ||
| pub(crate) event_params: CodexFileChangeEventParams, | ||
| } | ||
|
|
||
| #[derive(Serialize)] | ||
| pub(crate) struct CodexMcpToolCallEventParams { | ||
| #[serde(flatten)] | ||
| pub(crate) base: CodexToolItemEventBase, | ||
| pub(crate) mcp_server_name: String, | ||
| pub(crate) mcp_tool_name: String, | ||
| pub(crate) mcp_error_present: bool, | ||
| } | ||
|
|
||
| #[derive(Serialize)] | ||
| pub(crate) struct CodexMcpToolCallEventRequest { | ||
| pub(crate) event_type: &'static str, | ||
| pub(crate) event_params: CodexMcpToolCallEventParams, | ||
| } | ||
|
|
||
| #[derive(Serialize)] | ||
| pub(crate) struct CodexDynamicToolCallEventParams { | ||
| #[serde(flatten)] | ||
| pub(crate) base: CodexToolItemEventBase, | ||
| pub(crate) dynamic_tool_name: String, | ||
| pub(crate) success: Option<bool>, | ||
| pub(crate) output_content_item_count: Option<u64>, | ||
| pub(crate) output_text_item_count: Option<u64>, | ||
| pub(crate) output_image_item_count: Option<u64>, | ||
| } | ||
|
|
||
| #[derive(Serialize)] | ||
| pub(crate) struct CodexDynamicToolCallEventRequest { | ||
| pub(crate) event_type: &'static str, | ||
| pub(crate) event_params: CodexDynamicToolCallEventParams, | ||
| } | ||
|
|
||
| #[derive(Serialize)] | ||
| pub(crate) struct CodexCollabAgentToolCallEventParams { | ||
| #[serde(flatten)] | ||
| pub(crate) base: CodexToolItemEventBase, | ||
| pub(crate) sender_thread_id: String, | ||
| pub(crate) receiver_thread_count: u64, | ||
| pub(crate) receiver_thread_ids: Option<Vec<String>>, | ||
| pub(crate) requested_model: Option<String>, | ||
| pub(crate) requested_reasoning_effort: Option<String>, | ||
| pub(crate) agent_state_count: Option<u64>, | ||
| pub(crate) completed_agent_count: Option<u64>, | ||
| pub(crate) failed_agent_count: Option<u64>, | ||
| } | ||
|
|
||
| #[derive(Serialize)] | ||
| pub(crate) struct CodexCollabAgentToolCallEventRequest { | ||
| pub(crate) event_type: &'static str, | ||
| pub(crate) event_params: CodexCollabAgentToolCallEventParams, | ||
| } | ||
|
|
||
| #[derive(Serialize)] | ||
| pub(crate) struct CodexWebSearchEventParams { | ||
| #[serde(flatten)] | ||
| pub(crate) base: CodexToolItemEventBase, | ||
| pub(crate) web_search_action: Option<WebSearchActionKind>, | ||
| pub(crate) query_present: bool, | ||
| pub(crate) query_count: Option<u64>, | ||
| } | ||
|
|
||
| #[derive(Serialize)] | ||
| pub(crate) struct CodexWebSearchEventRequest { | ||
| pub(crate) event_type: &'static str, | ||
| pub(crate) event_params: CodexWebSearchEventParams, | ||
| } | ||
|
|
||
| #[derive(Serialize)] | ||
| pub(crate) struct CodexImageGenerationEventParams { | ||
| #[serde(flatten)] | ||
| pub(crate) base: CodexToolItemEventBase, | ||
| pub(crate) image_generation_status: String, | ||
| pub(crate) revised_prompt_present: bool, | ||
| pub(crate) saved_path_present: bool, | ||
| } | ||
|
|
||
| #[derive(Serialize)] | ||
| pub(crate) struct CodexImageGenerationEventRequest { | ||
| pub(crate) event_type: &'static str, | ||
| pub(crate) event_params: CodexImageGenerationEventParams, | ||
| } | ||
|
|
||
| #[derive(Serialize)] | ||
| pub(crate) struct CodexAppMetadata { | ||
| pub(crate) connector_id: Option<String>, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this just
guardian_review_count+user_review_count?