Skip to content

fix(gateway): queue followups during delegation#30241

Closed
BROCCOLO1D wants to merge 4 commits into
NousResearch:mainfrom
BROCCOLO1D:fix/30170-delegation-busy-queue
Closed

fix(gateway): queue followups during delegation#30241
BROCCOLO1D wants to merge 4 commits into
NousResearch:mainfrom
BROCCOLO1D:fix/30170-delegation-busy-queue

Conversation

@BROCCOLO1D

Copy link
Copy Markdown
Contributor

Summary

Why

  • In busy_input_mode: interrupt, a normal follow-up calls AIAgent.interrupt() on the parent, which recursively interrupts _active_children and kills in-flight delegate_task work.
  • While delegate_task blocks the parent synchronously, the safest minimal behavior is to preserve the child work and replay the follow-up after delegation completes.

Changes

  • gateway/run.py: detects active delegated children on the running parent agent and treats plain busy follow-ups as queue-mode instead of interrupt-mode.
  • gateway/run.py: sends a delegation-specific busy acknowledgement so users know the subagent is still working.
  • tests/gateway/test_busy_session_auth_bypass.py: covers the active-delegation path and preserves the existing interrupt behavior when no child is running.

Validation

  • .venv/bin/python -m pytest tests/gateway/test_busy_session_auth_bypass.py tests/gateway/test_restart_drain.py tests/gateway/test_status_command.py -o 'addopts=' -q
  • .venv/bin/python -m ruff check gateway/run.py tests/gateway/test_busy_session_auth_bypass.py

Scope

  • In scope: normal conversational messages arriving through the gateway while a parent agent has active delegated child agents.
  • Out of scope: steer-through to children, async delegation, and explicit cancel commands such as /stop or /new.

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery tool/delegate Subagent delegation P2 Medium — degraded but workaround exists labels May 22, 2026
@BROCCOLO1D

Copy link
Copy Markdown
Contributor Author

Duplicate-scope note: I found existing PR #30183 for the same #30170 bug after opening this. This PR keeps the scope to queueing conversational follow-ups while delegated children are active and is currently green; #30183 is the competing fix path but its test job is failing at the time of this check. Happy for maintainers to take either approach or close this one if #30183 is preferred.

@daimon-nous

daimon-nous Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

Reviewed in the #30170 triage. This PR handles the warm path (_handle_active_session_busy_message) but misses the cold PRIORITY path in _handle_message() (~L7228). Messages that go through the fast-path will still call running_agent.interrupt() and cascade to children. Also, the inline detection logic requires _active_children_lock to be non-None — returns False even with children when lock is None. See #30170 (comment) for the full comparison.

@BROCCOLO1D

Copy link
Copy Markdown
Contributor Author

Closing this partial duplicate after the #30170 triage. The current branch only covers the warm busy handler and misses the cold PRIORITY path, while #30183 covers both paths with stronger regression coverage and the /stop hint. I’ll leave the issue to the stronger candidate rather than churn this PR further.

@daimon-nous

daimon-nous Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

Merged via PR #32076 (#32076) using #30183's implementation, which covered both interrupt paths. Your fix addressed the same bug and was submitted first among the duplicates — credited in the triage. Thanks for the contribution! 🙏

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

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists 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