Skip to content

[codex-analytics] add protocol-native turn timestamps#16638

Merged
rhan-oai merged 1 commit intomainfrom
pr16638
Apr 6, 2026
Merged

[codex-analytics] add protocol-native turn timestamps#16638
rhan-oai merged 1 commit intomainfrom
pr16638

Conversation

@rhan-oai
Copy link
Copy Markdown
Collaborator

@rhan-oai rhan-oai commented Apr 3, 2026

Copy link
Copy Markdown
Collaborator

@owenlin0 owenlin0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these fields are going to be super helpful to have :)

pub turn: Turn,
/// Unix timestamp (in seconds) when the turn started.
#[ts(type = "number")]
pub created_at: i64,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we update the Turn object itself to have created_at, completed_at, and duration_ms fields? That way these are all persisted and exposed through all the various APIs like thread/read, thread/resume, etc.

That likely means we need to update EventMsg::TurnStarted and EventMsg::TurnCompleted to start storing timestamps, and unfortunately we'd probably have to also make the timestamps optional since historical turns won't have them. But I think the tradeoffs are worth it

event_turn_id: String,
status: TurnStatus,
error: Option<TurnError>,
turn_completion_metadata: TurnCompletionMetadata,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: status and error also feel like TurnCompletionMetadata, should we lump them together?

items: vec![],
error,
status,
created_at: None,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't feel great that this would always be None for all turn/completed notifications. Is there a way to populate it?

pub error: Option<TurnError>,
/// Unix timestamp (in seconds) when the turn started.
#[ts(type = "number | null")]
pub created_at: Option<i64>,
Copy link
Copy Markdown
Collaborator

@owenlin0 owenlin0 Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we rename this to be started_at? The reason is that there are two possible timestamps to be using:

  1. the timestamp of the turn/start RPC call
  2. the timestamp when the core turn operation (i.e. Op::UserInput) actually starts - core operations are queued

And it represents 2)

items,
error: None,
status: TurnStatus::InProgress,
created_at: None,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be populating created_at whenever we can. I see a lot of places where it's hardcoded to None 🤔

Copy link
Copy Markdown
Collaborator Author

@rhan-oai rhan-oai Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given the semantics of started_at, it doesn't make sense to populate these in app-server before core turn start as defined in turn_timing.rs is established

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, fair point!

turn_id: Some(turn_id.to_string()),
reason: codex_protocol::protocol::TurnAbortReason::Interrupted,
completed_at: None,
duration_ms: None,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: these are test helpers, right? could we populate these to some non-None values to be more representative?

@rhan-oai rhan-oai force-pushed the pr16638 branch 3 times, most recently from bbb42eb to 12d351f Compare April 6, 2026 18:23
@rhan-oai rhan-oai force-pushed the pr16638 branch 9 times, most recently from 5aec095 to 964a9a5 Compare April 6, 2026 21:57
@rhan-oai rhan-oai marked this pull request as ready for review April 6, 2026 23:22
@rhan-oai rhan-oai merged commit 756c45e into main Apr 6, 2026
27 of 30 checks passed
@rhan-oai rhan-oai deleted the pr16638 branch April 6, 2026 23:23
@github-actions github-actions bot locked and limited conversation to collaborators Apr 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants