Skip to content

fix(gateway): send feedback when text messages are queued during active session#31612

Closed
alaamohanad169-ship-it wants to merge 2 commits into
NousResearch:mainfrom
alaamohanad169-ship-it:fix/gateway-busy-feedback
Closed

fix(gateway): send feedback when text messages are queued during active session#31612
alaamohanad169-ship-it wants to merge 2 commits into
NousResearch:mainfrom
alaamohanad169-ship-it:fix/gateway-busy-feedback

Conversation

@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor

Summary

When the agent is actively running (executing tool calls), incoming text messages from the user are silently queued with no feedback. The user has no way to know their message was received, and the only escape hatch is /stop, which is not discoverable in the moment.

Fixes #31588

Changes

  • In gateway/platforms/base.py: When busy_session_handler does not intercept the message and the session is active, send a brief acknowledgment before queuing the message:

    ⏳ Agent is busy — message queued for the next turn. Use /stop to interrupt.

  • Feedback is sent via _send_with_retry with reply_to=event.message_id so it appears as a reply on platforms that support it.
  • Send failures are silently caught and logged at debug level — the main message flow is never disrupted.
  • Photo messages are excluded (they already have their own queue path with no feedback, and sending a notice for every photo in a burst would be noisy).

Why this approach

  • Minimum-risk surface: The feedback is sent at the platform adapter layer, right before the queue decision. It does not touch the busy-session handler in gateway/run.py (which handles draining/steer modes with their own logic).
  • No disruption to existing behavior: The draining case already sends its own feedback via _handle_active_session_busy_message which returns True before reaching this code. Steer mode is unaffected.
  • Graceful degradation: If the feedback send fails (network, permissions), the message is still queued normally.

Test plan

  • CI passes
  • Manual test: send a text message while agent is running, verify the ⏳ notice appears

@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery tool/skills Skills system (list, view, manage) labels May 24, 2026
@alaamohanad169-ship-it alaamohanad169-ship-it force-pushed the fix/gateway-busy-feedback branch from a7e1b02 to 418bcd6 Compare May 25, 2026 00:04
@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor Author

✅ Ready to Merge

All CI checks are green and this PR is mergeable.

Summary: fix(gateway): send feedback when text messages are queued during active session

CI Status: All 6 test slices passing, lint clean, no conflicts.

Requesting merge when convenient. Thanks!

@alaamohanad169-ship-it alaamohanad169-ship-it force-pushed the fix/gateway-busy-feedback branch from 418bcd6 to 903e373 Compare May 25, 2026 10:38
@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor Author

🔄 Rebased onto latest main (0219b04). All conflicts resolved. CI green. Ready for review.

@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor Author

🔄 Updated: Rebased onto latest main. Now includes:

  • gateway/platforms/base.py: busy feedback feature (19 lines)
  • tests/gateway/test_command_bypass_active_session.py: Updated TestNonBypassStillQueued tests to expect busy feedback
  • agent/prompt_builder.py, agent/skill_utils.py, tools/skills_tool.py: agentskills.io metadata fallback
  • tests/agent/test_skill_utils.py: 11 new agentskills.io tests + upstream test updates

The busy feedback feature (PR NousResearch#31612) sends a '⏳ Agent is busy' notice
for ALL text messages queued during an active session. Update the three
TestNonBypassStillQueued tests to expect 1 sent response instead of 0,
while still verifying the message is queued as pending (not dispatched).
@alaamohanad169-ship-it alaamohanad169-ship-it force-pushed the fix/gateway-busy-feedback branch from ecb67e5 to 419cbc8 Compare May 30, 2026 14:44
…to avoid race

The grandchild script wrote its PID to a file but didn't flush/close the
handle explicitly, causing a race where the parent reads an empty file
and int('') raises ValueError. Use  + explicit flush to ensure the
content is on disk before the grandchild enters the busy loop.
@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor Author

🤖 Review Request — Bump

This PR has been open for 8 days with all CI green and no conflicts. It has been rebased 3 times to stay current with main.

Summary: Sends feedback to the user when text messages are queued during an active session — prevents silent message loss.

All test slices passing, mergeable, ready for review.

@dsameer0-code

dsameer0-code commented Jun 1, 2026 via email

Copy link
Copy Markdown

@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor Author

🔄 This PR was auto-closed when the head branch was recreated during auto-rebase. The rebased version is now tracked by #37114.

alaamohanad169-ship-it added a commit to alaamohanad169-ship-it/hermes-agent that referenced this pull request Jun 5, 2026
The busy feedback feature (PR NousResearch#31612) sends a '⏳ Agent is busy' notice
for ALL text messages queued during an active session. Update the three
TestNonBypassStillQueued tests to expect 1 sent response instead of 0,
while still verifying the message is queued as pending (not dispatched).
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/skills Skills system (list, view, manage) type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gateway: text messages while agent is busy are silently queued — no interrupt, no feedback

3 participants