Skip to content

[codex] Attribute app-server analytics by thread originator#29935

Open
alexsong-oai wants to merge 1 commit into
mainfrom
codex/thread-originator-analytics
Open

[codex] Attribute app-server analytics by thread originator#29935
alexsong-oai wants to merge 1 commit into
mainfrom
codex/thread-originator-analytics

Conversation

@alexsong-oai

Copy link
Copy Markdown
Collaborator

Why

Desktop Work threads and regular Codex threads can share the same app-server connection. App-server analytics currently copy product_client_id from connection metadata for every thread-scoped event, so Work thread activity is attributed to the Desktop connection instead of the thread's resolved originator. This prevents analytics from distinguishing the two products on a shared connection.

What changed

  • Publish the resolved originator after a thread is materialized, covering new, resumed, forked, and subagent threads.
  • Store that originator in the analytics reducer's existing per-thread state.
  • Override only app_server_client.product_client_id for thread, turn, tool, review, goal, guardian, and compaction events while preserving the connection's client name, version, and transport metadata.
  • Fall back to the connection-wide product client ID when a thread has no originator override.
  • Preserve persisted originators in thread initialization analytics for resume and fork flows.

Validation

  • just test -p codex-analytics thread_originator_overrides_shared_connection_across_thread_events subagent_events_keep_thread_originator_with_explicit_turn_connection
  • just test -p codex-app-server turn_start_tracks_thread_originator_in_analytics thread_start_tracks_thread_initialized_analytics thread_fork_tracks_thread_initialized_analytics thread_resume_tracks_thread_initialized_analytics
  • just test -p codex-core thread_manager

@alexsong-oai alexsong-oai requested a review from a team as a code owner June 25, 2026 00:40
@alexsong-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 1f4391a50c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

pub fn set_thread_originator(&self, thread_id: String, originator: String) {
self.record_fact(AnalyticsFact::SetThreadOriginator {

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.

This cannot be a best-effort fact. If this drops but a later thread response gets through, we silently use the connection product ID for the rest of the thread. Can we carry the originator with the lifecycle fact or otherwise publish this state losslessly?

event,
&thread.id,
&thread.session_id,
"codex",

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.

This does not exercise the override: the persisted originator and connection product ID are both "codex", so it passes if SetThreadOriginator is never sent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants