mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Enrich thread archive analytics with thread context (#39797)
## What changed - Add app-server client, runtime, thread source, and parent thread ID metadata to archive and unarchive analytics events when the reducer has that context. - Omit non-automation feature thread sources and skip unavailable metadata. ## Testing - Cover archive and unarchive event enrichment, filtered feature sources, and threads without cached context. - Verify the app-server archive flow emits the enriched analytics payload. GitOrigin-RevId: 163f9c30721cee0172bb4581b6dcd269e44cd941
This commit is contained in:
1 parent
d9fd91edab
commit
cc801d7048
5 files changed
+198
-12
No files matched your search
@@ -140,11 +140,13 @@ use codex_app_server_protocol::SubAgentActivityKind;
|
||||
use codex_app_server_protocol::Thread;
|
||||
use codex_app_server_protocol::ThreadArchiveParams;
|
||||
use codex_app_server_protocol::ThreadArchiveResponse;
|
||||
use codex_app_server_protocol::ThreadArchivedNotification;
|
||||
use codex_app_server_protocol::ThreadItem;
|
||||
use codex_app_server_protocol::ThreadResumeResponse;
|
||||
use codex_app_server_protocol::ThreadSource as AppServerThreadSource;
|
||||
use codex_app_server_protocol::ThreadStartResponse;
|
||||
use codex_app_server_protocol::ThreadStatus as AppServerThreadStatus;
|
||||
use codex_app_server_protocol::ThreadUnarchivedNotification;
|
||||
use codex_app_server_protocol::Turn;
|
||||
use codex_app_server_protocol::TurnCompletedNotification;
|
||||
use codex_app_server_protocol::TurnDiffUpdatedNotification;
|
||||
@@ -2127,6 +2129,101 @@ async fn thread_originator_overrides_shared_connection_across_thread_events() {
|
||||
}),
|
||||
]
|
||||
);
|
||||
|
||||
reducer
|
||||
.ingest(
|
||||
AnalyticsFact::ClientResponse {
|
||||
connection_id: 7,
|
||||
request_id: RequestId::Integer(4),
|
||||
response: Box::new(sample_thread_resume_response_with_source(
|
||||
"thread-private-source",
|
||||
/*ephemeral*/ false,
|
||||
"gpt-5",
|
||||
AppServerSessionSource::Exec,
|
||||
Some(AppServerThreadSource::Feature(
|
||||
"private customer feature label".to_string(),
|
||||
)),
|
||||
Some("019ee5cf-4d15-77a2-8023-01a9f79b6e7d".to_string()),
|
||||
)),
|
||||
thread_originator: Some(TEST_PRODUCT_CLIENT_ID.to_string()),
|
||||
},
|
||||
&mut events,
|
||||
)
|
||||
.await;
|
||||
events.clear();
|
||||
|
||||
for notification in [
|
||||
ServerNotification::ThreadArchived(ThreadArchivedNotification {
|
||||
thread_id: "thread-work".to_string(),
|
||||
}),
|
||||
ServerNotification::ThreadUnarchived(ThreadUnarchivedNotification {
|
||||
thread_id: "thread-default".to_string(),
|
||||
}),
|
||||
ServerNotification::ThreadArchived(ThreadArchivedNotification {
|
||||
thread_id: "thread-private-source".to_string(),
|
||||
}),
|
||||
ServerNotification::ThreadUnarchived(ThreadUnarchivedNotification {
|
||||
thread_id: "thread-without-context".to_string(),
|
||||
}),
|
||||
] {
|
||||
reducer
|
||||
.ingest(
|
||||
AnalyticsFact::Notification(Box::new(notification)),
|
||||
&mut events,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
let mut archives = serde_json::to_value(&events).expect("serialize archive events");
|
||||
for event in archives.as_array_mut().expect("archive events") {
|
||||
assert!(event["event_params"]["occurred_at_ms"].is_u64());
|
||||
event["event_params"]
|
||||
.as_object_mut()
|
||||
.expect("archive event params")
|
||||
.remove("occurred_at_ms");
|
||||
}
|
||||
assert_eq!(
|
||||
archives,
|
||||
json!([
|
||||
{
|
||||
"event_type": "codex_thread_archive_event",
|
||||
"event_params": {
|
||||
"thread_id": "thread-work",
|
||||
"action": "archived",
|
||||
"app_server_client": initialized[0]["event_params"]["app_server_client"],
|
||||
"runtime": initialized[0]["event_params"]["runtime"],
|
||||
"thread_source": "user",
|
||||
},
|
||||
},
|
||||
{
|
||||
"event_type": "codex_thread_archive_event",
|
||||
"event_params": {
|
||||
"thread_id": "thread-default",
|
||||
"action": "unarchived",
|
||||
"app_server_client": initialized[1]["event_params"]["app_server_client"],
|
||||
"runtime": initialized[1]["event_params"]["runtime"],
|
||||
"thread_source": "user",
|
||||
},
|
||||
},
|
||||
{
|
||||
"event_type": "codex_thread_archive_event",
|
||||
"event_params": {
|
||||
"thread_id": "thread-private-source",
|
||||
"action": "archived",
|
||||
"app_server_client": initialized[0]["event_params"]["app_server_client"],
|
||||
"runtime": initialized[0]["event_params"]["runtime"],
|
||||
"parent_thread_id": "019ee5cf-4d15-77a2-8023-01a9f79b6e7d",
|
||||
},
|
||||
},
|
||||
{
|
||||
"event_type": "codex_thread_archive_event",
|
||||
"event_params": {
|
||||
"thread_id": "thread-without-context",
|
||||
"action": "unarchived",
|
||||
},
|
||||
}
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
Reference in new issue
Block a user