fix: preserve requester route for subagent completion delivery#72806
Conversation
Greptile SummaryThis PR fixes a Telegram routing bug where subagent completion announcements were incorrectly delivered to the child agent's external window/account instead of the original requester session. Two targeted fixes are made: Confidence Score: 5/5Safe to merge — minimal, well-targeted fix with a coherent test update confirming the corrected routing split. All three changed locations are self-consistent: the origin split in spawn, the session-key fix in announce-delivery, and the updated test expectations all align. No regressions introduced, no edge cases left unhandled. No files require special attention. Reviews (1): Last reviewed commit: "fix: preserve requester route for subage..." | Re-trigger Greptile |
|
Quick follow-up on the current red CI: I checked the failing jobs for this PR.
That failure appears to be in generated/base config schema baseline coverage (the diff mentions schema/help entries such as This PR intentionally only changes:
Local validation I ran for the final minimal patch: npx vitest --config test/vitest/vitest.agents.config.ts run \
src/agents/subagent-spawn.thread-binding.test.ts \
src/agents/subagent-spawn.test.tsThose targeted agent tests passed locally. I also did live Telegram validation for the exact bug this PR fixes:
With the final minimal patch, the completion correctly returned to the original requester conversation instead of the child agent / project-bot window. So at the moment the PR appears to be blocked by an unrelated schema/generated baseline failure rather than by the subagent routing fix itself. If maintainers want, I can also split this further or rebase onto a greener mainline once that schema failure is resolved. |
4e9471d to
b8fbd24
Compare
…law#72806) * fix: preserve requester route for subagent completion delivery * fix(agents): preserve requester subagent completion routes --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
…law#72806) * fix: preserve requester route for subagent completion delivery * fix(agents): preserve requester subagent completion routes --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
…law#72806) * fix: preserve requester route for subagent completion delivery * fix(agents): preserve requester subagent completion routes --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
…law#72806) * fix: preserve requester route for subagent completion delivery * fix(agents): preserve requester subagent completion routes --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
…law#72806) * fix: preserve requester route for subagent completion delivery * fix(agents): preserve requester subagent completion routes --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
…law#72806) * fix: preserve requester route for subagent completion delivery * fix(agents): preserve requester subagent completion routes --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
Summary
Fix subagent completion delivery so completion announcements route back to the original requester session/conversation instead of leaking into the child agent's bound external window/account.
Problem
We hit a real Telegram routing bug in cross-agent subagent runs:
main/defaultspawned a subagent targeting another agent (for examplenovel-agent)main/defaultchatThis was reproduced in real Telegram live validation, not just tests.
Root cause
There were two routing mistakes that compounded:
In
src/agents/subagent-spawn.ts, the registry storedrequesterOriginfrom the child-side delivery context (childSessionOrigin) instead of preserving the original requester route.In
src/agents/subagent-announce-delivery.ts, completion delivery routing resolved bound destinations usingparams.childSessionKeyand allowed non-fail-closed fallback.Fix
src/agents/subagent-spawn.tsrequesterOriginfrom the incoming requester contextchildSessionOriginseparately viaresolveRequesterOriginForChild(...)childSessionOriginrequesterOriginchildSessionOrigin, notrequesterOriginsrc/agents/subagent-announce-delivery.tsparams.requesterSessionKeyfailClosed: truefor completion delivery routingsrc/agents/subagent-spawn.thread-binding.test.tsValidation
Automated
Ran targeted agent tests:
Observed passing results on the final minimal patch.
Live verification
We also validated with real Telegram routing using a
novel-agentsubagent completion marker flow:main/defaultThe final minimal patch correctly delivered the completion back to the original
main/defaultconversation instead of theNovelbot window.Why this change is minimal
This PR intentionally keeps only the production fixes plus the single necessary thread-binding expectation update. Extra helper changes and regression-only scaffolding used during investigation were removed before preparing the PR.