Skip to content

fix(gateway): mark text-capture mode when base send_clarify renders choices as text#25584

Closed
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/issue-25567-clarify-text-fallback
Closed

fix(gateway): mark text-capture mode when base send_clarify renders choices as text#25584
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/issue-25567-clarify-text-fallback

Conversation

@liuhao1024

@liuhao1024 liuhao1024 commented May 14, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

When clarify is called with multiple choices on platforms that don't support inline buttons (Mattermost, etc.), the default send_clarify in BasePlatformAdapter renders choices as a numbered text list. The user replies with a number or text, but the gateway's text-intercept never fires because awaiting_text remains False. The agent blocks for 10 minutes and then times out.

Root Cause

clarify_gateway.register() sets awaiting_text = not bool(choices) (line 95). When choices are provided, awaiting_text is False. get_pending_for_session() (line 178) only returns entries with awaiting_text == True, so the user's text reply is never matched.

The base send_clarify in gateway/platforms/base.py renders choices as text but never calls mark_awaiting_text(clarify_id) to flip the flag. Adapters with inline buttons (Telegram, Discord) override send_clarify and resolve via button callbacks -- they don't hit this code path.

Related Issue

N/A

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • See commit messages for detailed changes

How to Test

  1. Run pytest tests/ -q — all tests should pass
  2. Verify the specific scenario described above is resolved

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 26.4.1

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture and workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A

Code Intelligence

GitNexus unavailable -- analysis skipped, grep-based fallback used.

  • Verified: get_pending_for_session called from gateway/run.py:5871 and gateway/platforms/base.py:2899 -- both are text-intercept paths
  • Verified: mark_awaiting_text called from gateway/platforms/telegram.py:2814 (button callback) -- confirms button platforms handle it separately
  • Blast radius: LOW -- only affects the default send_clarify path; adapters with button overrides are unaffected

Fixes Bug: clarify multiple-choice text fallback never intercepts user reply on Mattermost #25567

…hoices as text

When the default send_clarify renders multiple choices as a numbered text
list (platforms without inline buttons, e.g. Mattermost), the entry's
awaiting_text flag remained False.  get_pending_for_session only returns
entries with awaiting_text=True, so the user's text reply was never
intercepted and the agent timed out after 10 minutes.

Fix: call mark_awaiting_text(clarify_id) after rendering choices as text
in the base implementation.  Adapters that override send_clarify with
inline buttons (Telegram, Discord) do NOT reach this code path — they
resolve via button callbacks instead.

Fixes Bug: clarify multiple-choice text fallback never intercepts user reply on Mattermost NousResearch#25567
@liuhao1024 liuhao1024 force-pushed the fix/issue-25567-clarify-text-fallback branch from 6d04ad7 to e772be3 Compare May 15, 2026 03:28
@teknium1

Copy link
Copy Markdown
Contributor

This appears to be implemented on current main already.

Automated hermes-sweeper review evidence:

  • gateway/platforms/base.py:2504 now imports mark_awaiting_text in the base send_clarify text-fallback branch and gateway/platforms/base.py:2505 calls mark_awaiting_text(clarify_id) when choices are rendered as a numbered text list.
  • gateway/run.py:6553 uses get_pending_for_session(...) for the text intercept, and gateway/run.py:6563 resolves the clarify reply through resolve_gateway_clarify(...).
  • tools/clarify_gateway.py:95 keeps multi-choice clarifies non-text-awaiting by default, while tools/clarify_gateway.py:183 / tools/clarify_gateway.py:192 provide the flag flip that the base fallback now calls.
  • The implementing commit on main is f26098e22f17025b9d57b176898c7d60d5b5ce8b (fix(gateway): enable text-intercept for multi-choice clarify fallback (#25567)).

Thanks for the clear root-cause writeup here; the behavior this PR targets is now covered by the landed mainline fix.

@teknium1 teknium1 closed this Jun 12, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jun 12, 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 comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants