Skip to content

Add forked_from_thread_id turn metadata#24160

Merged
owenlin0 merged 9 commits into
mainfrom
owen/forked_from_thread_id
May 26, 2026
Merged

Add forked_from_thread_id turn metadata#24160
owenlin0 merged 9 commits into
mainfrom
owen/forked_from_thread_id

Conversation

@owenlin0

@owenlin0 owenlin0 commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Why

When Codex calls responsesapi, we currently send session_id, thread_id, and turn_id among other things as client_metadata["x-codex-turn-metadata"]. This PR adds forked_from_thread_id which helps explain the "lineage" of a forked thread.

What's changed

  • Track the immediate history source copied into a forked thread through thread/session creation, including subagent and review turn metadata paths.
  • Include forked_from_thread_id in Codex turn metadata while preventing turn-scoped Responses API client metadata from overwriting Codex-owned lineage fields.
  • Add coverage for fork lineage in turn metadata and the app-server Responses API request path.

@owenlin0 owenlin0 force-pushed the owen/forked_from_thread_id branch from 458564d to 9051b29 Compare May 26, 2026 00:46
@owenlin0 owenlin0 force-pushed the owen/forked_from_thread_id branch 2 times, most recently from f4a05f8 to 8287c25 Compare May 26, 2026 15:27
@owenlin0 owenlin0 marked this pull request as ready for review May 26, 2026 16:22
@owenlin0 owenlin0 requested a review from a team as a code owner May 26, 2026 16:22
@owenlin0 owenlin0 requested review from aibrahim-oai and jif-oai May 26, 2026 16:25

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8287c259e6

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

Comment thread codex-rs/core/src/turn_metadata.rs Outdated
Comment thread codex-rs/core/src/agent/control.rs
Comment thread codex-rs/core/src/session/review.rs

@jif-oai jif-oai left a comment

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.

Most enterprise proxy reject _ in headers or metadata. Could we use - instead please?

Comment thread codex-rs/core/src/codex_delegate.rs Outdated
extensions: Arc::clone(&parent_session.services.extensions),
conversation_history: initial_history.unwrap_or(InitialHistory::New),
session_source: SessionSource::SubAgent(subagent_source.clone()),
forked_from_thread_id: 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.

Should this really be none here? Shouldn't we use the parent thread for reviews?

@owenlin0 owenlin0 force-pushed the owen/forked_from_thread_id branch from 2682fb1 to 65f6b05 Compare May 26, 2026 19:54
@owenlin0 owenlin0 merged commit 1911021 into main May 26, 2026
31 checks passed
@owenlin0 owenlin0 deleted the owen/forked_from_thread_id branch May 26, 2026 21:05
@github-actions github-actions Bot locked and limited conversation to collaborators May 26, 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