feat: seed root trajectory id + drop vestigial open action#6
Merged
Merged
Conversation
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>
39fff2f to
361f037
Compare
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.
Stacked on #5 (program-close); base will retarget to
mainonce #5 lands.Related PRs (radix-native sessions):
--enable-session-radix-cache(tag +release_session, per-node holder set).session_control).agent_context+session_control, and now seeds the root trajectory soparent_trajectory_idflows.Verified end-to-end with all three together (GLM-4.7-Flash TP2,
--router-mode kv):parent_trajectory_idflows from a real spawned subagent, noaction:open, andrelease_sessionfrees on close.What
Two radix-native subagent-session lifecycle fixes:
Root trajectory seed.
applySubagentBridgeonly populatesparent_trajectory_idwhen a child inherits a non-emptyDYN_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 zeroparent_trajectory_iddespite the bridge being wired.seedRootTrajectory()seeds it at the root (trace on, not aPI_SUBAGENT_CHILD, id unset; prefersDYN_AGENT_SESSION_ID) so spawned subagents now carry a parent.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.controlForTurnnow emits a baresession_ideach turn; tagging and sticky routing are unchanged (the router activates on anysession_control), close is unchanged.Also fixes pre-existing
tscerrors inprogram-close.test.ts(optional handler invocation undernoUncheckedIndexedAccess) sonpm run checkis 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. newseedRootTrajectorycases (root seeds → child resolves a parent; usesDYN_AGENT_SESSION_ID; no-ops for non-root/trace-off/preset) and updated no-opencontrolForTurnassertionsDYN_AGENT_TRAJECTORY_ID) →seedRootTrajectoryfires → real spawned child (pi-subagents env contract) → trace records the child withparent_trajectory_id= root's id andtrajectory_id=run:researcher:0(wasnullin the captured 12×4 run).controlForTurnemitted a baresession_id(noaction:open). KV release also verified live in--router-mode kv: the sticky KV router dispatches the deferredclose_sessionon inlineaction:"close"-> worker ->release_session(freed 2 nodeson a real-prompt session; the provider's own chat-path close also dispatches,freed 0only when the session is sub-page). In--router-mode round-robinthe sticky lifecycle doesn't run, so no close dispatch — a router-mode requirement, not a regression (open-drop didn't touch close).