hermes - ✅(Solved) Fix Bug: gateway sessions expose clarify tool but never wire clarify_callback [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#12573Fetched 2026-04-20 12:18:09
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1

clarify is exposed in gateway sessions, but Telegram/gateway-created agents do not wire a clarify_callback, so the tool immediately returns:

Clarify tool is not available in this execution context.

Error Message

  • In this Telegram chat, calling clarify directly reproduces the error live.
  • tools/clarify_tool.py returns that exact error when callback is None.

Root Cause

Gateway sessions instantiate and cache AIAgent instances, but only set per-message progress/status/stream callbacks. They never attach a clarify callback, so the tool schema exists but the user-interaction bridge is missing.

Fix Action

Fixed

PR fix notes

PR #12576: fix(gateway): wire clarify callback for messaging sessions

Description (problem / solution / changelog)

Summary

  • wire a gateway-side clarify_callback into gateway-created agents
  • track pending clarify prompts per session and consume the next user reply
  • add regression tests for callback round-trip, response coercion, and agent wiring

Test Plan

  • source /Users/wondermonkey/.hermes/hermes-agent/venv/bin/activate && python -m pytest tests/gateway/test_clarify_callback.py -q

Closes #12573

Changed files

  • gateway/run.py (modified, +127/-2)
  • tests/gateway/test_clarify_callback.py (added, +174/-0)
RAW_BUFFERClick to expand / collapse

Summary

clarify is exposed in gateway sessions, but Telegram/gateway-created agents do not wire a clarify_callback, so the tool immediately returns:

Clarify tool is not available in this execution context.

Repro

  1. Start Hermes gateway on Telegram.
  2. In a Telegram DM, ask the agent to use clarify (or trigger it directly).
  3. The tool call fails immediately instead of showing a prompt.

What I verified

  • In this Telegram chat, calling clarify directly reproduces the error live.
  • tools/clarify_tool.py returns that exact error when callback is None.
  • run_agent.py documents the contract: the platform layer must provide clarify_callback, otherwise the tool errors.
  • CLI wires clarify_callback=self._clarify_callback.
  • Gateway _run_agent() did not set agent.clarify_callback, so gateway-created AIAgent instances always saw None.

Root cause

Gateway sessions instantiate and cache AIAgent instances, but only set per-message progress/status/stream callbacks. They never attach a clarify callback, so the tool schema exists but the user-interaction bridge is missing.

Expected behavior

Gateway-created agents should provide a working clarify callback so messaging platforms can collect the next user reply (at minimum via text prompt + reply).

Telegram could later be upgraded to inline buttons, but the immediate regression is simpler: the callback is not wired at all.

Proposed fix

  • Add a gateway-side clarify callback builder.
  • Track pending clarify prompts per session.
  • Intercept the next user message to resolve the pending clarify response.
  • Assign agent.clarify_callback = ... in _run_agent() alongside the other per-message callbacks.

Regression coverage

Add gateway tests proving:

  • the callback round-trips a user response,
  • pending clarify replies are consumed and normalized,
  • _run_agent() wires clarify_callback onto the agent.

extent analysis

TL;DR

Implement a gateway-side clarify callback builder to wire agent.clarify_callback and track pending clarify prompts per session.

Guidance

  • Verify that agent.clarify_callback is None in gateway-created AIAgent instances by checking the run_agent.py contract and the tools/clarify_tool.py error message.
  • To mitigate the issue, assign agent.clarify_callback in _run_agent() alongside other per-message callbacks, and implement a callback builder to track pending clarify prompts per session.
  • Intercept the next user message to resolve the pending clarify response and ensure the callback round-trips a user response.
  • Add gateway tests to prove the callback works as expected and pending clarify replies are consumed and normalized.

Example

def _run_agent(self, ...):
    # ...
    agent.clarify_callback = self._build_clarify_callback()
    # ...

def _build_clarify_callback(self):
    # Implement callback builder to track pending clarify prompts per session
    # and intercept the next user message to resolve the pending clarify response
    pass

Notes

The proposed fix requires implementing a gateway-side clarify callback builder and tracking pending clarify prompts per session. This may involve modifying the _run_agent() method and adding new functionality to handle clarify callbacks.

Recommendation

Apply workaround by implementing the proposed fix, as it directly addresses the root cause of the issue and provides a clear path to resolving the problem.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Gateway-created agents should provide a working clarify callback so messaging platforms can collect the next user reply (at minimum via text prompt + reply).

Telegram could later be upgraded to inline buttons, but the immediate regression is simpler: the callback is not wired at all.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING