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
- Start Hermes gateway on Telegram.
- In a Telegram DM, ask the agent to use
clarify (or trigger it directly).
- 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.
Summary
clarifyis exposed in gateway sessions, but Telegram/gateway-created agents do not wire aclarify_callback, so the tool immediately returns:Clarify tool is not available in this execution context.Repro
clarify(or trigger it directly).What I verified
clarifydirectly reproduces the error live.tools/clarify_tool.pyreturns that exact error whencallback is None.run_agent.pydocuments the contract: the platform layer must provideclarify_callback, otherwise the tool errors.clarify_callback=self._clarify_callback._run_agent()did not setagent.clarify_callback, so gateway-createdAIAgentinstances always sawNone.Root cause
Gateway sessions instantiate and cache
AIAgentinstances, 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
agent.clarify_callback = ...in_run_agent()alongside the other per-message callbacks.Regression coverage
Add gateway tests proving:
_run_agent()wiresclarify_callbackonto the agent.