Skip to content

fix(gateway): allow exec-type quick commands to bypass draining guard#28734

Open
zccyman wants to merge 1 commit into
NousResearch:mainfrom
atyou2happy:fix/exec-quick-command-draining-bypass
Open

fix(gateway): allow exec-type quick commands to bypass draining guard#28734
zccyman wants to merge 1 commit into
NousResearch:mainfrom
atyou2happy:fix/exec-quick-command-draining-bypass

Conversation

@zccyman

@zccyman zccyman commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Exec-type quick commands (quick_commands.<name>.type: exec) now bypass the _draining guard in GatewayRunner._handle_message(), ensuring they remain available when the gateway is shutting down or restarting.

These commands run pure shell subprocesses via asyncio.create_subprocess_shell and do not depend on the agent loop or LLM backend — there is no reason to block them during draining. In practice, this means ops commands (health checks, service status, etc.) are accessible when the system is most unhealthy and you need them the most.

Changes

  • gateway/run.py: Added exec-type quick command dispatch before the _draining guard. The original dispatch block after the guard is kept as a defensive fallback with a comment. Alias-type quick commands and regular slash commands remain blocked during draining as they may require the agent loop.
  • tests/gateway/test_exec_quick_command_draining.py: 6 new tests covering exec commands while draining, timeout handling, error reporting, empty command, non-draining regression, and unknown command blocking.

Testing

  • 6/6 new tests pass
  • 16/16 existing test_restart_drain.py tests pass (no regression)
  • 18/18 existing test_quick_commands.py tests pass (no regression)

Complementary with PR #25804

PR #25804 fixes exec quick commands being blocked when the agent is mid-turn (_handle_active_session_busy_message path). This PR fixes the same class of issue but for the draining trigger condition in _handle_message. Both fixes are complementary — one handles mid-turn, the other handles draining.

Closes #28663

Exec-type quick commands run pure shell subprocesses via
asyncio.create_subprocess_shell and do not depend on the agent
loop or LLM backend. They should remain available during gateway
draining (after SIGTERM or repeated LLM failures) so that ops
commands are accessible when the system is most unhealthy.

Move the exec-type quick command dispatch before the _draining
guard in _handle_message(). Alias-type quick commands and regular
slash commands remain blocked during draining as they may need
the agent loop.

Closes NousResearch#28663

Co-authored-by: zccyman <16263913+zccyman@users.noreply.github.com>
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists labels May 19, 2026
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 type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exec-type quick commands are blocked when gateway is draining

2 participants