mirror of
https://github.com/openai/codex.git
synced 2026-10-22 17:58:46 +00:00
Track history notes thread hint outcomes (#42247)
## What changed - Emit a `codex_thread_hint_status` analytics event for each native history-notes thread hint attempt. - Report whether retrieval was successful or failed along with thread context and timing, without including hint contents. - Treat valid empty responses as successful retrievals while continuing to omit them from the context window. ## Testing - Extend the app-server history-notes tests to verify success, empty-result success, and backend failure statuses. GitOrigin-RevId: b9462f312847e8c871ed2be0c8cf8df0928a7fdd
This commit is contained in:
@@ -505,6 +505,12 @@ impl AnalyticsEventsClient {
|
||||
))));
|
||||
}
|
||||
|
||||
pub fn track_thread_hint_status(&self, event: crate::thread_hint::ThreadHintStatusEvent) {
|
||||
self.record_fact(AnalyticsFact::Custom(
|
||||
CustomAnalyticsFact::ThreadHintStatus(Box::new(event)),
|
||||
));
|
||||
}
|
||||
|
||||
pub fn track_image_preparation(&self, fact: ImagePreparationFact) {
|
||||
self.record_fact(AnalyticsFact::Custom(
|
||||
CustomAnalyticsFact::ImagePreparation(Box::new(fact)),
|
||||
|
||||
@@ -76,6 +76,7 @@ pub(crate) enum TrackEventRequest {
|
||||
HookRun(CodexHookRunEventRequest),
|
||||
Compaction(Box<CodexCompactionEventRequest>),
|
||||
Goal(Box<CodexGoalEventRequest>),
|
||||
ThreadHintStatus(Box<crate::thread_hint::ThreadHintStatusEventRequest>),
|
||||
TurnEvent(Box<CodexTurnEventRequest>),
|
||||
TurnSteer(CodexTurnSteerEventRequest),
|
||||
ArtifactOperation(CodexArtifactOperationEventRequest),
|
||||
|
||||
@@ -566,6 +566,7 @@ pub(crate) enum CustomAnalyticsFact {
|
||||
SubAgentThreadStarted(SubAgentThreadStartedInput),
|
||||
Compaction(Box<CodexCompactionEvent>),
|
||||
Goal(Box<CodexGoalEvent>),
|
||||
ThreadHintStatus(Box<crate::thread_hint::ThreadHintStatusEvent>),
|
||||
GuardianReview(Box<GuardianReviewEventParams>),
|
||||
GuardianV2(Box<GuardianV2Event>),
|
||||
TurnResolvedConfig(Box<TurnResolvedConfigFact>),
|
||||
|
||||
@@ -6,6 +6,7 @@ mod events;
|
||||
mod facts;
|
||||
mod guardian_v2;
|
||||
mod reducer;
|
||||
mod thread_hint;
|
||||
|
||||
use std::time::SystemTime;
|
||||
use std::time::UNIX_EPOCH;
|
||||
@@ -74,6 +75,8 @@ pub use facts::TurnTokenUsageFact;
|
||||
pub use facts::build_track_events_context;
|
||||
pub use guardian_v2::GuardianV2Event;
|
||||
pub use guardian_v2::GuardianV2EventKind;
|
||||
pub use thread_hint::ThreadHintStatus;
|
||||
pub use thread_hint::ThreadHintStatusEvent;
|
||||
|
||||
#[cfg(test)]
|
||||
mod analytics_client_tests;
|
||||
|
||||
@@ -621,6 +621,34 @@ impl AnalyticsReducer {
|
||||
CustomAnalyticsFact::Goal(input) => {
|
||||
self.ingest_goal(*input, out);
|
||||
}
|
||||
CustomAnalyticsFact::ThreadHintStatus(input) => {
|
||||
if let Some((connection, thread, metadata)) =
|
||||
self.thread_context_or_warn(AnalyticsDropSite {
|
||||
event_name: "codex_thread_hint_status",
|
||||
thread_id: &input.thread_id,
|
||||
turn_id: None,
|
||||
review_id: None,
|
||||
item_id: None,
|
||||
})
|
||||
{
|
||||
out.push(TrackEventRequest::ThreadHintStatus(Box::new(
|
||||
crate::thread_hint::ThreadHintStatusEventRequest {
|
||||
event_type: "codex_thread_hint_status",
|
||||
event_params: crate::thread_hint::ThreadHintStatusEventParams {
|
||||
thread_id: input.thread_id,
|
||||
session_id: metadata.session_id.clone(),
|
||||
app_server_client: thread.app_server_client(connection),
|
||||
runtime: connection.runtime.clone(),
|
||||
thread_source: metadata.thread_source.clone(),
|
||||
subagent_source: metadata.subagent_source.clone(),
|
||||
parent_thread_id: metadata.parent_thread_id.clone(),
|
||||
status: input.status,
|
||||
occurred_at_ms: input.occurred_at_ms,
|
||||
},
|
||||
},
|
||||
)));
|
||||
}
|
||||
}
|
||||
CustomAnalyticsFact::GuardianV2(input) => {
|
||||
let event_type = match &input.kind {
|
||||
GuardianV2EventKind::Classification { .. } => {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
//! Per-attempt thread hint status analytics without hint contents.
|
||||
|
||||
use crate::events::CodexAppServerClientMetadata;
|
||||
use crate::events::CodexRuntimeMetadata;
|
||||
use codex_protocol::protocol::ThreadSource;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ThreadHintStatus {
|
||||
Succeeded,
|
||||
Failed,
|
||||
}
|
||||
|
||||
pub struct ThreadHintStatusEvent {
|
||||
pub thread_id: String,
|
||||
pub status: ThreadHintStatus,
|
||||
pub occurred_at_ms: u64,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub(crate) struct ThreadHintStatusEventRequest {
|
||||
pub(crate) event_type: &'static str,
|
||||
pub(crate) event_params: ThreadHintStatusEventParams,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub(crate) struct ThreadHintStatusEventParams {
|
||||
pub(crate) thread_id: String,
|
||||
pub(crate) session_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) status: ThreadHintStatus,
|
||||
pub(crate) occurred_at_ms: u64,
|
||||
}
|
||||
Reference in New Issue
Block a user