fix(delegation): route async results to origin session - #59767
Closed
dschnurbusch wants to merge 1 commit into
Closed
fix(delegation): route async results to origin session#59767dschnurbusch wants to merge 1 commit into
dschnurbusch wants to merge 1 commit into
Conversation
Carry the live TUI session id with async delegation completion events and prefer the commissioning UI session when desktop pollers share the completion queue. Resolve compressed session keys to their continuation before treating events as orphaned, and capture the live parent agent session id for TUI/ACP dispatch.
dschnurbusch
force-pushed
the
fix/async-delegation-origin-routing
branch
from
July 6, 2026 17:22
4cc7655 to
00eff97
Compare
Contributor
|
Merged via PR #60863 — your commit was cherry-picked onto current main with your authorship preserved in git log, plus a follow-up commit adding fail-closed orphan handling (unowned delegation payloads are never adopted by a foreign session) and session-scoped delegation lifecycle (a closing session interrupts its own in-flight subagents). The origin_ui_session_id return-address design and the compression-chain resolution were exactly the right shape — thanks for the thorough cross-referencing against the sibling PRs in your body text. |
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
Fix async
delegate_taskcompletions in desktop/TUI so results return to the session that commissioned the subagent, even when context compression rotates the durable session id while the child is running.HERMES_UI_SESSION_ID/origin_ui_session_idreturn address with async delegation completion eventsparent_agent.session_idinstead of only the approval/session-context keyWhy
Desktop/TUI sessions share one process-wide completion queue. If an async delegation completion only carries a durable
session_key, and that key goes stale after context compression/session rotation, another session poller can consume the event and inject the delegated result into the wrong conversation.Related PRs
I found related open PRs while checking for duplicate work: #58690, #57535, and #57586. This PR is a focused variant for the desktop/TUI path that adds a live UI return address plus compression-chain resolution rather than relying only on the durable session key.
Verification
deleg_586ecc5e; result returned to the commissioning session withDELEGATION_ROUTING_SMOKE_OK_20260706_1317python -m py_compile gateway/session_context.py tools/async_delegation.py tools/delegate_tool.py tui_gateway/server.pypython -m pytest tests/tools/test_async_delegation.py::test_delegate_task_background_routes_async_and_does_not_block tests/tools/test_async_delegation.py::test_delegate_task_background_uses_live_tui_agent_session_id tests/tools/test_async_delegation.py::test_delegate_task_background_batch_runs_as_one_unit tests/test_tui_gateway_server.py::test_notification_event_routing_by_session_key tests/test_tui_gateway_server.py::test_async_delegation_event_prefers_origin_ui_session tests/test_tui_gateway_server.py::test_notification_event_follows_compression_continuation tests/test_tui_gateway_server.py::test_finalized_origin_ui_session_falls_back_to_live_continuation tests/gateway/test_session_env.py tests/gateway/test_session_context_inheritance.py -q -o 'addopts='→ 29 passedpython -m pytest tests/tools/test_async_delegation.py tests/gateway/test_session_env.py tests/gateway/test_session_context_inheritance.py -q -o 'addopts='→ 43 passedgit diff --checkmergeable=MERGEABLE,mergeStateStatus=CLEAN