mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
store and expose parent_thread_id on Threads (#25113)
## Why This PR https://github.com/openai/codex/pull/24161#discussion_r3325692763 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.
This commit is contained in:
1 parent
3b7334d099
commit
cf0911076f
92 files changed
+504
-111
No files matched your search
@@ -62,6 +62,8 @@ pub struct ThreadItem {
|
||||
pub git_origin_url: Option<String>,
|
||||
/// Session source from session metadata.
|
||||
pub source: Option<SessionSource>,
|
||||
/// Immediate control/spawn parent thread id from session metadata.
|
||||
pub parent_thread_id: Option<ThreadId>,
|
||||
/// Random unique nickname from session metadata for AgentControl-spawned sub-agents.
|
||||
pub agent_nickname: Option<String>,
|
||||
/// Role (agent_role) from session metadata for AgentControl-spawned sub-agents.
|
||||
@@ -95,6 +97,7 @@ struct HeadTailSummary {
|
||||
git_sha: Option<String>,
|
||||
git_origin_url: Option<String>,
|
||||
source: Option<SessionSource>,
|
||||
parent_thread_id: Option<ThreadId>,
|
||||
agent_nickname: Option<String>,
|
||||
agent_role: Option<String>,
|
||||
model_provider: Option<String>,
|
||||
@@ -778,6 +781,7 @@ async fn build_thread_item(
|
||||
git_sha,
|
||||
git_origin_url,
|
||||
source,
|
||||
parent_thread_id,
|
||||
agent_nickname,
|
||||
agent_role,
|
||||
model_provider,
|
||||
@@ -799,6 +803,7 @@ async fn build_thread_item(
|
||||
git_sha,
|
||||
git_origin_url,
|
||||
source,
|
||||
parent_thread_id,
|
||||
agent_nickname,
|
||||
agent_role,
|
||||
model_provider,
|
||||
@@ -1101,6 +1106,7 @@ async fn read_head_summary(path: &Path, head_limit: usize) -> io::Result<HeadTai
|
||||
RolloutItem::SessionMeta(session_meta_line) => {
|
||||
if !summary.saw_session_meta {
|
||||
summary.source = Some(session_meta_line.meta.source.clone());
|
||||
summary.parent_thread_id = session_meta_line.meta.parent_thread_id;
|
||||
summary.agent_nickname = session_meta_line.meta.agent_nickname.clone();
|
||||
summary.agent_role = session_meta_line.meta.agent_role.clone();
|
||||
summary.model_provider = session_meta_line.meta.model_provider.clone();
|
||||
|
||||
Reference in new issue
Block a user