[codex-analytics] add queued submission metadata

This commit is contained in:
rhan-oai
2026-04-02 22:06:55 -07:00
parent 0e16d53fb7
commit 48a7e70eec
57 changed files with 447 additions and 7 deletions

View File

@@ -101,6 +101,13 @@ pub const REALTIME_CONVERSATION_OPEN_TAG: &str = "<realtime_conversation>";
pub const REALTIME_CONVERSATION_CLOSE_TAG: &str = "</realtime_conversation>";
pub const USER_MESSAGE_BEGIN: &str = "## My request for Codex:";
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "snake_case")]
pub enum SubmissionType {
Prompt,
PromptQueued,
}
/// Submission Queue Entry - requests from user
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct Submission {
@@ -244,6 +251,19 @@ pub enum Op {
final_output_json_schema: Option<Value>,
},
/// Same transport shape as [`Op::UserInput`], but preserves submission
/// metadata for analytics.
UserInputWithMetadata {
/// User input items, see `InputItem`
items: Vec<UserInput>,
/// Optional JSON Schema used to constrain the final assistant message for this turn.
#[serde(skip_serializing_if = "Option::is_none")]
final_output_json_schema: Option<Value>,
/// Metadata describing how the prompt was submitted.
#[serde(default, skip_serializing_if = "Option::is_none")]
submission_type: Option<SubmissionType>,
},
/// Similar to [`Op::UserInput`], but contains additional context required
/// for a turn of a [`crate::codex_thread::CodexThread`].
UserTurn {
@@ -299,6 +319,10 @@ pub enum Op {
/// Optional personality override for this turn.
#[serde(skip_serializing_if = "Option::is_none")]
personality: Option<Personality>,
/// Metadata describing how the prompt was submitted.
#[serde(default, skip_serializing_if = "Option::is_none")]
submission_type: Option<SubmissionType>,
},
/// Inter-agent communication that should be recorded as assistant history
@@ -579,6 +603,7 @@ impl Op {
Self::RealtimeConversationText(_) => "realtime_conversation_text",
Self::RealtimeConversationClose => "realtime_conversation_close",
Self::UserInput { .. } => "user_input",
Self::UserInputWithMetadata { .. } => "user_input",
Self::UserTurn { .. } => "user_turn",
Self::InterAgentCommunication { .. } => "inter_agent_communication",
Self::OverrideTurnContext { .. } => "override_turn_context",