fix(server): preserve parentAgentId for Codex tasks discovered via activity - #167
Draft
pandec wants to merge 2 commits into
Draft
fix(server): preserve parentAgentId for Codex tasks discovered via activity#167pandec wants to merge 2 commits into
pandec wants to merge 2 commits into
Conversation
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Note
Preview of an upstream PR for
pingdotgg/t3code. Never merge this;mainhere is a clean upstream mirror. Close once the upstream PR is open.Problem
A Codex child task discovered only through a
collabAgent/activitynotification loses its parent. The activity fallback path builttask.startedwithoutparentAgentId, while thecollabAgent/startedpath preserved it (apps/server/src/provider/Layers/CodexAdapter.ts). Children that surface this way render as roots, so the task hierarchy breaks.Fix
The
subAgentActivityitem itself carries no parent field, but the enclosing notification envelope'sthreadIdis the spawning thread for astartedactivity (per the app-server emission path; verified against the generated schema and the captured multi-agent wire fixture). So:CodexSessionRuntimerecords that envelopethreadIdas the child's parent when registering a child from astartedactivity — authoritativethread/startedspawn metadata always outranks it — and forwards it on the synthetic events, including the sharedchildIdentityused by turn/status lifecycle rows.CodexAdaptercarriesparentAgentIdinstatusLinkage, so it is repeated on started, updated, token-usage, and item progress rows alike. This follows the contract's requirement (packages/contracts/src/providerRuntime.ts) that identity linkage rides every lifecycle row: with the 500-row activity retention cap, a child whosetask.startedages out is reconstructed from later rows, and the parent must survive that. The twotask.startedbuilders are also deduped into one helper so the paths cannot drift apart again.Ref.modifyinstead of update-then-read.Verification
startedactivity emitstask.startedwith the right parent;interactedactivity emits no start; bothtask.startedroutes carry the parent; status and both progress-row builders repeat it; explicit spawn metadata beats the envelope inference; nested root → A → B linkage attributes B to A, not the root.started-only condition or the existing-parent precedence each turns a test red.vp checkandvp run typecheckclean.[screenshot placeholder, optional: agents sidebar showing a Codex subagent nested under its parent after the fix, flat at root level before]
Notes
subagentRuntimetreats anyparentAgentIdasworkflow_agent. Activity-discovered children now get the same classification thecollabAgent/startedpath already produced; no rendering site keys off that kind today, and such children stay in the direct list. Making the client represent native (non-workflow) hierarchies is a separate discussion.Relationship to pingdotgg#6416
pingdotgg#6416 also carries
parentAgentIdthrough the activity path, as one piece of a 23-file feature surfacing managed Codex runs; it is currently conflicting and has unresolved review findings. This PR fixes only the hierarchy defect, mergeable independently. Happy to close this one if pingdotgg#6416 lands first. Related child-task work: pingdotgg#7507, pingdotgg#7585.Implemented by gpt-5.6-sol, orchestrated and reviewed (opus + sol panel) in Claude Code (Fable 5).