Skip to content

fix: /status command bypasses active-session guard during agent run#5080

Closed
teyrebaz33 wants to merge 1 commit into
NousResearch:mainfrom
teyrebaz33:fix/status-command-during-active-agent
Closed

fix: /status command bypasses active-session guard during agent run#5080
teyrebaz33 wants to merge 1 commit into
NousResearch:mainfrom
teyrebaz33:fix/status-command-during-active-agent

Conversation

@teyrebaz33

Copy link
Copy Markdown
Contributor

Problem

Fixes #5046.

When an agent was actively processing a message, sending /status via Telegram (or any gateway platform) caused it to be silently queued as a pending interrupt rather than being dispatched as a system command. The user would receive no status response, and the running agent would be interrupted unexpectedly on the next turn.

Root Cause

BasePlatformAdapter.handle_message() in gateway/platforms/base.py already had bypass logic for /approve and /deny commands — these are dispatched directly to the message handler even when a session is active, because they must not interrupt the running agent. /status was missing the same treatment and fell through to the default interrupt path.

Fix

Apply the same bypass pattern to cmd == 'status': detect it inside the active-session guard, call _message_handler directly, send the response via _send_with_retry, and return without touching session lifecycle or interrupt state.

What is not addressed

  • Behavior 2 (context mismatch): Could not reproduce. No code path found that would cause this.
  • Behavior 3 (termination semantics): The cooperative interruption model is an intentional design choice. No change made.

Tests

Added test_status_command_bypasses_active_session_guard to tests/gateway/test_status_command.py. Verifies that handle_message("/status") dispatches immediately even when _active_sessions contains an active entry, sends the response, does not set the interrupt event, and does not queue the event.

…ousResearch#5046)

When an agent was actively processing a message, /status sent via Telegram
(or any gateway) was queued as a pending interrupt instead of being dispatched
immediately. The base platform adapter's handle_message() only had special-case
bypass logic for /approve and /deny, so /status fell through to the default
interrupt path and was never processed as a system command.

Apply the same bypass pattern used by /approve//deny: detect cmd == 'status'
inside the active-session guard, dispatch directly to the message handler, and
send the response without touching session lifecycle or interrupt state.

Adds a regression test that verifies /status is dispatched and responded to
immediately even when _active_sessions contains an entry for the session.
@teknium1

teknium1 commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Merged via PR #5288 (consolidated bugfix salvage). Your commit(s) were cherry-picked onto current main with your authorship preserved in git log. Thanks @teyrebaz33 for the fix!

@teknium1 teknium1 closed this Apr 5, 2026
teyrebaz33 added a commit to teyrebaz33/hermes-agent that referenced this pull request Apr 7, 2026
Comprehensive walkthrough covering:
- Three methods for finding bugs (usage, code reading, open issues)
- Verifying a real bug before writing code
- Tracing root causes through the full code path
- Opening well-structured issues
- Writing minimal, pattern-following fixes
- Writing regression tests
- Pre-PR checklist with exact commands
- Opening PRs with clear descriptions
- Handling CI failures and the salvage pattern

All examples drawn from real merged PRs (NousResearch#5080, NousResearch#5829).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Telegram passes /status to agent instead of a system call returning metrics

2 participants