fix(delegate): pin async completion to spawning parent session (#57498) - #57535
Closed
nankingjing wants to merge 1 commit into
Closed
fix(delegate): pin async completion to spawning parent session (#57498)#57535nankingjing wants to merge 1 commit into
nankingjing wants to merge 1 commit into
Conversation
…esearch#57498) Background delegate_task completions only carried session_key. When multiple active sessions shared a routing peer, get_or_create_session could recover the latest ended_at IS NULL row and inject the subagent result into the wrong session. Capture parent_agent.session_id at dispatch time, include it on async-delegation completion events, and pin gateway routing via switch_session when the synthetic completion message is handled. Fixes NousResearch#57498
5 tasks
Contributor
|
Merged via PR #60871 — your commit was cherry-picked onto current main with your authorship preserved in git log, plus a follow-up commit completing the class: the pinning now fails closed when the spawning session has ended (switch_session re-opens ended sessions, so blind pinning could resurrect a /new-ended conversation), and /new now interrupts the old conversation's in-flight delegations via a parent_session_id selector. Your parent-session pin was the keystone that made both possible — thanks! |
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.
Summary
delegate_task(background=true)completions could re-enter the wrong gateway session when multiple active rows shared the same routing peer. The async registry only carriedsession_key; on injection,get_or_create_session()could recover the latestended_at IS NULLsession instead of the session that spawned the subagent.tools/delegate_tool.py: captureparent_agent.session_idat dispatch timetools/async_delegation.py: carryparent_session_idon completion events (single + batch)gateway/run.py: passgateway_session_idon synthetic completionMessageEventmetadata; pin routing withswitch_session()before handling the turnFixes #57498
Scope note
Short-term fix from the issue (carry parent session id). Session lifecycle /
ended_atleaks and cross-channelsession_keyreuse are separate follow-ups.Test plan
pytest tests/tools/test_async_delegation.py::test_completion_event_lands_on_shared_queue_with_session_key -q