Skip to content

store and expose parent_thread_id on Threads#25113

Draft
owenlin0 wants to merge 4 commits into
mainfrom
owen/improve_subagent_data_modeling
Draft

store and expose parent_thread_id on Threads#25113
owenlin0 wants to merge 4 commits into
mainfrom
owen/improve_subagent_data_modeling

Conversation

@owenlin0
Copy link
Copy Markdown
Collaborator

@owenlin0 owenlin0 commented May 29, 2026

Why

This PR #24161 (comment) revealed a subagent data modeling issue, where we overloaded forked_from_id to also mean parent_thread_id. That's incorrect since guardian and review subagents can be a subagent and NOT fork the main thread's history.

The solution here is to explicitly store a new parent_thread_id on SessionMeta, alongside forked_from_id which already exists. While we're at it, also expose it in the app-server protocol on the Thread object.

A thread->subagent relationship and a fork of thread history are orthogonal concepts.

What Changed

  • Added top-level parent_thread_id persistence on SessionMeta and runtime/session plumbing through SessionConfiguredEvent, CodexSpawnArgs, SessionConfiguration, ThreadConfigSnapshot, TurnContext, and ModelClient.
  • Made turn metadata, request headers, analytics, and subagent-start events read the separate runtime/top-level parent field instead of deriving general parent lineage from SessionSource or forked_from_thread_id.
  • Passed parent lineage separately at delegated subagent, review, guardian, agent-job, and multi-agent spawn construction sites; copied-history fork lineage remains derived only from InitialHistory.
  • Persisted and exposed parent lineage through rollout/thread-store projections and app-server v2 Thread.parentThreadId.
  • Updated app-server README text and regenerated app-server schema fixtures for the additive parentThreadId response field.

@owenlin0 owenlin0 changed the title Owen/improve subagent data modeling Model subagent parent lineage in source May 29, 2026
@owenlin0 owenlin0 changed the title Model subagent parent lineage in source Model subagent parent lineage separately from source May 29, 2026
@owenlin0 owenlin0 force-pushed the owen/improve_subagent_data_modeling branch from 79f0199 to 5019c4d Compare May 29, 2026 18:30
@owenlin0 owenlin0 changed the title Model subagent parent lineage separately from source expose a reliable parent_thread_id on Threads May 29, 2026
@owenlin0 owenlin0 force-pushed the owen/improve_subagent_data_modeling branch 4 times, most recently from 5e9ee64 to 21583d8 Compare May 29, 2026 22:19
@owenlin0 owenlin0 changed the title expose a reliable parent_thread_id on Threads store and expose parent_thread_id on Threads May 29, 2026
Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai left a comment

Choose a reason for hiding this comment

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

lgtm if you're sure it does not break anything in the app UX for multi-agent (I guess not but double check please)

})?;
if let Ok(meta_line) = read_session_meta_line(path.as_path()).await {
thread.forked_from_id = meta_line.meta.forked_from_id;
thread.parent_thread_id = meta_line.meta.parent_thread_id;
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.

Just for the record: this is not backward compatible
But it's good for now

@owenlin0 owenlin0 force-pushed the owen/improve_subagent_data_modeling branch from 21583d8 to 17702d3 Compare May 30, 2026 20:38
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