[codex-analytics] rework thread_source for thread analytics#20949
Merged
Conversation
8ff56a5 to
bc57b39
Compare
be1be00 to
321a6cc
Compare
40c394b to
b13e5bc
Compare
414156a to
f4d5073
Compare
08ee4fa to
a57b5d9
Compare
b79e86b to
ec2466c
Compare
owenlin0
approved these changes
May 5, 2026
ec2466c to
17fe52e
Compare
17fe52e to
7686157
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
thread_sourcean explicit optional thread-level field onthread/start,thread/fork, and returned thread payloadsthread_sourcein rollout/session metadata so resumed live threads retain the original valuesession_source->thread_sourcemapping with an explicit caller-supplied analytics classificationWhy
Before this change, analytics
thread_sourcewas populated by a best-effort mapping fromsession_source.session_sourcedescribes the runtime/client surface, not the actual thread-level origin, so that projection was not accurate enough to distinguish cases such asuser,subagent,memory_consolidation, and future thread origins reliably.Making
thread_sourceexplicit keeps one thread-level analytics field while letting callers provide the real classification directly instead of recovering it indirectly fromsession_source.Impact
For new analytics events,
thread_sourcenow reflects the explicit thread-level classification supplied by the caller rather than an inferred value derived fromsession_source. Existing protocol fields remain optional; callers that omitthreadSourcenow producenullinstead of a best-effort inferred value.Validation
just write-app-server-schemacargo test -p codex-analytics -p codex-core -p codex-app-server-protocol --no-runcargo test -p codex-app-server-protocol generated_ts_optional_nullable_fields_only_in_paramscargo test -p codex-analytics thread_initialized_event_serializes_expected_shapecargo test -p codex-core resume_stopped_thread_from_rollout_preserves_thread_source