Skip to content

fix(gateway): bypass slash commands during pending update prompts#15849

Closed
Yukipukii1 wants to merge 1 commit into
NousResearch:mainfrom
Yukipukii1:fix/gateway-update-command-bypass
Closed

fix(gateway): bypass slash commands during pending update prompts#15849
Yukipukii1 wants to merge 1 commit into
NousResearch:mainfrom
Yukipukii1:fix/gateway-update-command-bypass

Conversation

@Yukipukii1

@Yukipukii1 Yukipukii1 commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Summary

This fixes a gateway control-flow bug where a pending /update prompt could consume real slash commands like /new or /help as if they were update responses.

While _update_prompt_pending[session_key] was set, _handle_message() intercepted the next message before normal command dispatch. That worked for plain text answers and /approve//deny, but it also swallowed recognized gateway commands and wrote them to .update_response instead of executing them.

This PR narrows that interception path so recognized slash commands bypass the update-response flow and continue through normal gateway dispatch.

It also clears _update_prompt_pending during real session-boundary transitions, alongside the existing approval-state cleanup, so stale update prompt state does not leak across /new, /resume, or /branch.

Problem

Before this change:

  1. Trigger an update flow that leaves _update_prompt_pending[session_key] = True
  2. Send /new (or another recognized slash command)
  3. The gateway writes /new into .update_response
  4. The session command never runs

That is the wrong control-plane behavior. Session/control commands should not be reinterpreted as update prompt answers.

Fix

  • In gateway/run.py, when an update prompt is pending:
    • keep treating /approve and /deny as shorthand yes/no responses
    • keep accepting plain text replies as update responses
    • but bypass interception for recognized slash commands so they dispatch normally
  • Extend _clear_session_boundary_security_state() to also clear _update_prompt_pending for the target session

Tests

Added regression coverage for:

  • recognized slash commands bypassing pending update prompt interception
  • _update_prompt_pending being cleared on session-boundary cleanup
  • /resume and /branch preserving scoped cleanup behavior for other sessions

Test result:

21 passed, 3 warnings

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery labels Apr 26, 2026
teknium1 added a commit that referenced this pull request Apr 27, 2026
When the gateway intercepts a pending /update prompt and the user sends
a recognized slash command (/new, /help, ...), the command now dispatches
normally AND the detached update subprocess is unblocked by writing a
blank .update_response. _gateway_prompt reads '' → strips → returns the
prompt's default (typically a safe 'n' / skip), so the update process
exits cleanly instead of blocking on stdin until the 30-minute watcher
timeout.

Also clears _update_prompt_pending[session_key] on this path so stray
future input for the same session isn't re-intercepted.

Extends PR #15849 with tests for the new cancel-write + a regression
test pinning the legacy behavior of unrecognized /foo slash commands
still being consumed as the response.
@teknium1

Copy link
Copy Markdown
Contributor

Merged via #16289. Your commit bdaf56a94 is on main with your authorship preserved via rebase-merge. Thanks!

A follow-up commit (90c84c6db) was added on top to also write a blank .update_response when a recognized slash command bypasses the update-prompt interception — this unblocks the detached hermes update subprocess immediately (its _gateway_prompt returns the prompt default on empty) instead of leaving it zombie-waiting on stdin until the 30-minute watcher timeout.

ulasbilgen pushed a commit to ulasbilgen/hermes-adhd-agent that referenced this pull request May 1, 2026
When the gateway intercepts a pending /update prompt and the user sends
a recognized slash command (/new, /help, ...), the command now dispatches
normally AND the detached update subprocess is unblocked by writing a
blank .update_response. _gateway_prompt reads '' → strips → returns the
prompt's default (typically a safe 'n' / skip), so the update process
exits cleanly instead of blocking on stdin until the 30-minute watcher
timeout.

Also clears _update_prompt_pending[session_key] on this path so stray
future input for the same session isn't re-intercepted.

Extends PR NousResearch#15849 with tests for the new cancel-write + a regression
test pinning the legacy behavior of unrecognized /foo slash commands
still being consumed as the response.
donald131 pushed a commit to donald131/hermes-agent that referenced this pull request May 2, 2026
When the gateway intercepts a pending /update prompt and the user sends
a recognized slash command (/new, /help, ...), the command now dispatches
normally AND the detached update subprocess is unblocked by writing a
blank .update_response. _gateway_prompt reads '' → strips → returns the
prompt's default (typically a safe 'n' / skip), so the update process
exits cleanly instead of blocking on stdin until the 30-minute watcher
timeout.

Also clears _update_prompt_pending[session_key] on this path so stray
future input for the same session isn't re-intercepted.

Extends PR NousResearch#15849 with tests for the new cancel-write + a regression
test pinning the legacy behavior of unrecognized /foo slash commands
still being consumed as the response.
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
When the gateway intercepts a pending /update prompt and the user sends
a recognized slash command (/new, /help, ...), the command now dispatches
normally AND the detached update subprocess is unblocked by writing a
blank .update_response. _gateway_prompt reads '' → strips → returns the
prompt's default (typically a safe 'n' / skip), so the update process
exits cleanly instead of blocking on stdin until the 30-minute watcher
timeout.

Also clears _update_prompt_pending[session_key] on this path so stray
future input for the same session isn't re-intercepted.

Extends PR NousResearch#15849 with tests for the new cancel-write + a regression
test pinning the legacy behavior of unrecognized /foo slash commands
still being consumed as the response.
dannyJ848 pushed a commit to dannyJ848/hermes-agent that referenced this pull request May 17, 2026
When the gateway intercepts a pending /update prompt and the user sends
a recognized slash command (/new, /help, ...), the command now dispatches
normally AND the detached update subprocess is unblocked by writing a
blank .update_response. _gateway_prompt reads '' → strips → returns the
prompt's default (typically a safe 'n' / skip), so the update process
exits cleanly instead of blocking on stdin until the 30-minute watcher
timeout.

Also clears _update_prompt_pending[session_key] on this path so stray
future input for the same session isn't re-intercepted.

Extends PR NousResearch#15849 with tests for the new cancel-write + a regression
test pinning the legacy behavior of unrecognized /foo slash commands
still being consumed as the response.
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
When the gateway intercepts a pending /update prompt and the user sends
a recognized slash command (/new, /help, ...), the command now dispatches
normally AND the detached update subprocess is unblocked by writing a
blank .update_response. _gateway_prompt reads '' → strips → returns the
prompt's default (typically a safe 'n' / skip), so the update process
exits cleanly instead of blocking on stdin until the 30-minute watcher
timeout.

Also clears _update_prompt_pending[session_key] on this path so stray
future input for the same session isn't re-intercepted.

Extends PR NousResearch#15849 with tests for the new cancel-write + a regression
test pinning the legacy behavior of unrecognized /foo slash commands
still being consumed as the response.
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
When the gateway intercepts a pending /update prompt and the user sends
a recognized slash command (/new, /help, ...), the command now dispatches
normally AND the detached update subprocess is unblocked by writing a
blank .update_response. _gateway_prompt reads '' → strips → returns the
prompt's default (typically a safe 'n' / skip), so the update process
exits cleanly instead of blocking on stdin until the 30-minute watcher
timeout.

Also clears _update_prompt_pending[session_key] on this path so stray
future input for the same session isn't re-intercepted.

Extends PR NousResearch#15849 with tests for the new cancel-write + a regression
test pinning the legacy behavior of unrecognized /foo slash commands
still being consumed as the response.
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.

3 participants