Skip to content

fix(delegation): scope async-delegation interrupts by profile owner (#6949) - #88108

Open
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/6949-delegation-owner-profile
Open

webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/6949-delegation-owner-profile

Conversation

@webtecnica

Copy link
Copy Markdown
Contributor

What Changed

Adds a durable owner_profile to async delegation records and requires owner_profile AND (session_key OR origin_ui_session_id OR parent_session_id) in interrupt_for_session/has_live_for_session, so deleting a session can never cooperatively-stop a live background delegation belonging to a different Hermes profile. Backward-compatible: callers that pass no owner keep the previous OR semantics.

Root Cause

The async delegation registry is process-global and interrupt_for_session combined the three selectors (session_key/origin_ui_session_id/parent_session_id) with pure OR logic, WITHOUT a profile owner. Session IDs are NOT unique across profiles — deleting a session in one profile could interrupt a live background delegation from another profile.

Verification

New isolation test: two profiles sharing the same session key — interrupt scoped to profile A only stops A's delegation (count=1), never B's. Backward-compat test: without owner_profile, the original OR behavior is preserved. All 39 existing delegation tests pass.

Closes #6949

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/tools Tool registry, model_tools, toolsets tool/delegate Subagent delegation sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Aug 17, 2026
@Enough1122

Copy link
Copy Markdown
Contributor

AI code review — automated review for reference; please use your judgment.

  1. tools/async_delegation.py:_matches_session_selectors — Positive: owner_profile scoping is implemented as an AND over (profile match, at least one selector) rather than replacing the selector OR — so a profile-scoped interrupt can never leak across profiles on a colliding session_key/UI id, while every existing caller that omits the parameter keeps the exact legacy OR semantics (all pinned by tests, including has_live_for_session). The durable owner_profile column with additive ALTER TABLE and restart-recovery restore means post-crash delegations keep correct ownership too.

  2. Nit: the fix only protects surfaces that actually pass owner_profile down to interrupt_for_session/has_live_for_session. Worth a quick audit that gateway session-end and /new-reset paths in multiplex mode supply it — otherwise those callers silently retain the old cross-profile OR behavior. No change requested beyond confirming that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state tool/delegate Subagent delegation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants