Skip to content

feat(core): persist trace_id for turns in RolloutItem::TurnContext#13602

Merged
owenlin0 merged 1 commit intomainfrom
owen/add_trace_id_to_persisted_turns
Mar 5, 2026
Merged

feat(core): persist trace_id for turns in RolloutItem::TurnContext#13602
owenlin0 merged 1 commit intomainfrom
owen/add_trace_id_to_persisted_turns

Conversation

@owenlin0
Copy link
Copy Markdown
Collaborator

@owenlin0 owenlin0 commented Mar 5, 2026

This PR adds a durable trace linkage for each turn by storing the active trace ID on the rollout TurnContext record stored in session rollout files.

Before this change, we propagated trace context at runtime but didn’t persist a stable per-turn trace key in rollout history. That made after-the-fact debugging harder (for example, mapping a historical turn to the corresponding trace in datadog). This sets us up for much easier debugging in the future.

What changed

  • Added an optional trace_id to TurnContextItem (rollout schema).
  • Added a small OTEL helper to read the current span trace ID.
  • Captured trace_id when creating TurnContext and included it in to_turn_context_item().
  • Updated tests and fixtures that construct TurnContextItem so older/no-trace cases still work.

Why this approach

TurnContext is already the canonical durable per-turn metadata in rollout. This keeps ownership clean: trace linkage lives with other persisted turn metadata.

@owenlin0 owenlin0 force-pushed the owen/add_trace_id_to_persisted_turns branch from 6a0eb95 to 45c680c Compare March 5, 2026 18:59
@owenlin0 owenlin0 changed the title feat(core): add trace_id to persisted turns Mar 5, 2026
@owenlin0 owenlin0 marked this pull request as ready for review March 5, 2026 19:06
@owenlin0
Copy link
Copy Markdown
Collaborator Author

owenlin0 commented Mar 5, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

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

ℹ️ 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".

@owenlin0 owenlin0 changed the title feat(core): persist trace_id for turns in in RolloutItem::TurnContext Mar 5, 2026
@owenlin0 owenlin0 enabled auto-merge (squash) March 5, 2026 21:26
@owenlin0 owenlin0 disabled auto-merge March 5, 2026 21:26
@owenlin0 owenlin0 merged commit aa3fe8a into main Mar 5, 2026
29 of 31 checks passed
@owenlin0 owenlin0 deleted the owen/add_trace_id_to_persisted_turns branch March 5, 2026 21:26
@github-actions github-actions bot locked and limited conversation to collaborators Mar 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

2 participants