Skip to content

feat: seed root trajectory id + drop vestigial open action#6

Merged
ishandhanani merged 6 commits into
mainfrom
idhanani/root-trajectory-seed-implicit-open
Jun 16, 2026
Merged

feat: seed root trajectory id + drop vestigial open action#6
ishandhanani merged 6 commits into
mainfrom
idhanani/root-trajectory-seed-implicit-open

Conversation

@ishandhanani

@ishandhanani ishandhanani commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #5 (program-close); base will retarget to main once #5 lands.

Related PRs (radix-native sessions):

Verified end-to-end with all three together (GLM-4.7-Flash TP2, --router-mode kv): parent_trajectory_id flows from a real spawned subagent, no action:open, and release_session frees on close.

What

Two radix-native subagent-session lifecycle fixes:

  1. Root trajectory seed. applySubagentBridge only populates parent_trajectory_id when a child inherits a non-empty DYN_AGENT_TRAJECTORY_ID. The root never set one, so the first generation of pi-subagents had nothing to inherit — the bridge no-opped and every agent showed up as its own flat top-level session (session_id == trajectory_id, no parent). This is exactly why a captured 12×4 subagent run had zero parent_trajectory_id despite the bridge being wired. seedRootTrajectory() seeds it at the root (trace on, not a PI_SUBAGENT_CHILD, id unset; prefers DYN_AGENT_SESSION_ID) so spawned subagents now carry a parent.

  2. Drop the vestigial open action. The radix-native backend is close-only / implicit-open (the tag is the only session state); the first turn's action:"open" was already ignored by the worker. controlForTurn now emits a bare session_id each turn; tagging and sticky routing are unchanged (the router activates on any session_control), close is unchanged.

Also fixes pre-existing tsc errors in program-close.test.ts (optional handler invocation under noUncheckedIndexedAccess) so npm run check is green.

Test plan

  • npm run check — clean (was red on the base due to the program-close.test.ts errors above)
  • npm test — 40 passing, incl. new seedRootTrajectory cases (root seeds → child resolves a parent; uses DYN_AGENT_SESSION_ID; no-ops for non-root/trace-off/preset) and updated no-open controlForTurn assertions
  • E2E: full stack live (Dynamo #10214 + SGLang #27058 radix worker, GLM-4.7-Flash TP2 + this provider). Root (no DYN_AGENT_TRAJECTORY_ID) → seedRootTrajectory fires → real spawned child (pi-subagents env contract) → trace records the child with parent_trajectory_id = root's id and trajectory_id=run:researcher:0 (was null in the captured 12×4 run). controlForTurn emitted a bare session_id (no action:open). KV release also verified live in --router-mode kv: the sticky KV router dispatches the deferred close_session on inline action:"close" -> worker -> release_session (freed 2 nodes on a real-prompt session; the provider's own chat-path close also dispatches, freed 0 only when the session is sub-page). In --router-mode round-robin the sticky lifecycle doesn't run, so no close dispatch — a router-mode requirement, not a regression (open-drop didn't touch close).

@ishandhanani ishandhanani changed the base branch from idhanani/program-close to main June 16, 2026 07:10
Two radix-native subagent-session lifecycle fixes:

1. Root trajectory seed. applySubagentBridge only populates
   parent_trajectory_id when a child inherits a non-empty
   DYN_AGENT_TRAJECTORY_ID. The root never set one, so the first
   generation of pi-subagents had nothing to inherit -- the bridge
   no-opped and every agent appeared as its own flat top-level session
   (session_id == trajectory_id, no parent). seedRootTrajectory() seeds
   it at the root (trace on, not a PI_SUBAGENT_CHILD, id unset; prefers
   DYN_AGENT_SESSION_ID), so spawned subagents now carry
   parent_trajectory_id.

2. Drop the vestigial open action. The radix-native backend is
   close-only / implicit-open (the tag is the only session state); the
   first turn's action:"open" was ignored. controlForTurn now emits a
   bare session_id each turn; close is unchanged.

Also fixes pre-existing tsc errors in program-close.test.ts (optional
handler invocation under noUncheckedIndexedAccess).

Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>
Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>
Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>
Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>
Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>
@ishandhanani ishandhanani force-pushed the idhanani/root-trajectory-seed-implicit-open branch from 39fff2f to 361f037 Compare June 16, 2026 07:10
@ishandhanani ishandhanani merged commit 5c237a1 into main Jun 16, 2026
1 check failed
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.

1 participant