[Feat] surface spawnedBy in chat and agent broadcast payloads#63244
[Feat] surface spawnedBy in chat and agent broadcast payloads#63244frankekn merged 4 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryAdds a Confidence Score: 5/5Safe to merge — additive, backward-compatible change with 8 targeted tests covering all new broadcast paths. All changes are additive (optional field, absent for non-subagent sessions), implementation is correct, caching logic properly handles the undefined/null distinction, and every modified broadcast site is covered by new tests. The acknowledged null-cache risk for sessions where the spawnedBy PATCH hasn't completed is mitigated by the stated ordering invariant in subagent-spawn.ts, and no P0/P1 issues were found. No files require special attention.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 732bf30c36
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
732bf30 to
4ea8a0b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4ea8a0b80f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex /review |
|
To use Codex here, create an environment for this repo. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7753208275
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
7753208 to
94540b6
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 94540b6532
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
94540b6 to
249eb88
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 249eb885fa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
94540b6 to
ef4f577
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ef4f57788e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
ef4f577 to
c5a46e9
Compare
|
Codex review: needs changes before merge. Keep this PR open. Current main still does not implement the requested optional Required change before merge: Keep this PR open and review or land the latest version if it adds optional Best possible solution: Keep this PR open and review or land the latest version if it adds optional What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 71473e7448f9. |
|
Thanks for the focused protocol/test coverage. One issue before we prepare this: the current For subagent/ACP sessions it calls Local review evidence:
|
Subagent sessions emitted chat and agent broadcast events with only sessionKey. Clients had to follow up with sessions.subscribe to learn the parent, creating a timing race. Inject spawnedBy at the six previously uncovered broadcast sites (emitChatDelta, flushBufferedChatDeltaIfNeeded, emitChatFinal done + error, seq gap error, non-tool agent event). resolveSpawnedBy reads from the session store directly. It short-circuits for session keys that cannot carry lineage (mirrors supportsSpawnLineage in sessions-patch.ts), so the hot chat delta path does not touch the store for normal sessions. No cache: spawnedBy is immutable once set, and the only frequent caller is the subagent/acp hot path which is already filtered by the lineage key check. Signed-off-by: samzong <samzong.lu@gmail.com>
Signed-off-by: samzong <samzong.lu@gmail.com>
73b8211 to
ff0fe5d
Compare
|
Merged via squash.
Thanks @samzong! |
Summary
chatandagentbroadcast events with onlysessionKeybut nospawnedByfield. Clients cannot determine session parentage from the first event without an extrasessions.subscriberound-trip, creating a structural race condition.resolveSpawnedBy()helper insidecreateAgentEventHandlerand injectedspawnedByinto all 6 broadcast sites that were missing it:emitChatDelta,flushBufferedChatDeltaIfNeeded,emitChatFinal(done + error), agent seq gap error, and non-tool agent events.buildSessionEventSnapshotpaths (already includespawnedBy), companion spawn metadata fields (spawnedWorkspaceDir,spawnDepth, etc.), and downstream client adaptations.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
N/A — new feature, not a bug fix.
Regression Test Plan (if applicable)
src/gateway/server-chat.agent-events.test.tsspawnedByfor subagent sessions and omit it for non-subagent sessions; cache resolves once per sessionKey.loadGatewaySessionRowand verify payload shape at each broadcast call site.spawnedByinbuildSessionEventSnapshotpaths; new tests cover the 6 previously uncovered broadcast sites.User-visible / Behavior Changes
chatevents (delta,final,error) and non-toolagentevents now include aspawnedByfield when the emitting session is a subagent. Non-subagent sessions are unchanged (field absent).Diagram (if applicable)
Security Impact (required)
Repro + Verification
Environment
Steps
chatandagentWebSocket events from subagent sessionsspawnedByfield is present in payloadsExpected
chatand non-toolagentbroadcasts from subagent sessions includespawnedByActual
Evidence
Human Verification (required)
Review Conversations
Compatibility / Migration
Risks and Mitigations