hermes - ✅(Solved) Fix [Feature]: Add on_clarify plugin hook [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#12815Fetched 2026-04-20 12:16:48
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
referenced ×3renamed ×2cross-referenced ×1

Error Message

Add an on_clarify hook that fires when the clarify tool runs, with kwargs matching existing hook conventions (question, choices, session_id, model, platform). Fire it post-validation, so it only triggers when the tool will actually block on a callback, not on malformed calls that immediately error.

  • Fire the hook from the agent dispatcher instead of inside the tool. Rejected: duplicates across the concurrent/sequential dispatch paths and fires even for malformed tool calls that will immediately error.

Fix Action

Fix / Workaround

  • Fire the hook from the agent dispatcher instead of inside the tool. Rejected: duplicates across the concurrent/sequential dispatch paths and fires even for malformed tool calls that will immediately error.
  • Overload pre_tool_call with a tool_name == "clarify" filter. Rejected: every plugin would have to inspect every pre-tool-call to find the ones it cares about; a dedicated hook is discoverable via VALID_HOOKS and keeps handlers single-purpose.

PR fix notes

PR #12814: feat(cli): fire on_clarify plugin hook when clarify tool runs

Description (problem / solution / changelog)

What does this PR do?

Fires the new on_clarify plugin hook when the agent invokes the clarify tool, so plugins (e.g. a desktop-notifier) can alert the user when the agent is blocked waiting for input.

The hook is invoked inside tools/clarify_tool.py after input validation — not at the agent dispatcher — so:

  • It fires only when the tool will actually block on a callback; malformed calls (empty question, missing callback, wrong choices type) short-circuit before the hook is called, so plugins don't get spurious notifications for no-op errors.
  • It sees the normalized choices (stripped + trimmed to MAX_CHOICES) that the user will actually be shown, not the raw model output.
  • Both the concurrent and sequential tool-dispatch paths in run_agent.py share the same fire-site by construction.

Plugin exceptions are caught and logged as warnings, never propagate to the tool.

For reference, this is the Hermes analogue of Claude Code's AskUserQuestion hook (see Claude Code hooks).

Related Issue

Fixes #12815

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • hermes_cli/plugins.py: add on_clarify to VALID_HOOKS.
  • tools/clarify_tool.py: extend signature with session_id/model/platform (default "", backward-compatible); fire on_clarify after validation and before the platform callback; propagate the new kwargs through the registry handler.
  • run_agent.py: pass session_id/model/platform into clarify_tool from both the concurrent (_invoke_tool) and sequential (_execute_tool_calls_sequential) dispatch paths.
  • tests/tools/test_clarify_hook.py: 7 new tests covering normalized kwargs, validation gating (empty question, missing callback, invalid choices type), hook-failure isolation, open-ended questions, and VALID_HOOKS registration.
  • website/docs/user-guide/features/hooks.md: add on_clarify row to the Quick reference table and a full section with signature, fire-site, use cases, and a macOS desktop-notification example.
  • website/docs/user-guide/features/plugins.md: add on_clarify to the "Available hooks" summary table.
  • website/docs/guides/build-a-hermes-plugin.md: add on_clarify row (with callback signature) to the hook reference table.
  • website/docs/developer-guide/agent-loop.md: note on_clarify fires from inside clarify_tool alongside the interactive-tool exception.

How to Test

  1. Run the new and existing clarify tests together:
    pytest tests/tools/test_clarify_hook.py tests/tools/test_clarify_tool.py -q
    Expected: 27 passed.
  2. To exercise the hook end-to-end, register a dummy plugin hook and invoke clarify:
    ctx.register_hook("on_clarify", lambda **kw: print("NOTIFY", kw["question"]))
    Then in a Hermes session ask the agent to use the clarify tool. Expected: NOTIFY ... prints before the prompt renders. Invalid args (empty question) should NOT trigger the print.
  3. Confirm that plugin exceptions don't break the tool: have the hook raise RuntimeError; the tool should still collect the user's answer.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (feat(cli): ...)
  • 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 15 (Darwin 25.4.0)

Documentation & Housekeeping

  • I've updated relevant documentation — added on_clarify section in hooks.md; added rows in plugins.md, build-a-hermes-plugin.md, and a note in agent-loop.md; extended clarify_tool docstring with the new kwargs; fire-and-forget semantics noted inline.
  • N/A — no config keys added.
  • N/A — no architecture / workflow change.
  • Cross-platform: pure-Python additions, no OS-specific code.
  • N/A — tool schema for clarify unchanged; new kwargs are plumbing between agent and tool, not part of the model-facing schema.

Screenshots / Logs

$ pytest tests/tools/test_clarify_hook.py tests/tools/test_clarify_tool.py -q
...........................                                              [100%]
27 passed in 1.61s

Changed files

  • hermes_cli/plugins.py (modified, +1/-0)
  • run_agent.py (modified, +6/-0)
  • tests/tools/test_clarify_hook.py (added, +117/-0)
  • tools/clarify_tool.py (modified, +30/-1)
  • website/docs/developer-guide/agent-loop.md (modified, +4/-0)
  • website/docs/guides/build-a-hermes-plugin.md (modified, +1/-0)
  • website/docs/user-guide/features/hooks.md (modified, +48/-0)
  • website/docs/user-guide/features/plugins.md (modified, +1/-0)
RAW_BUFFERClick to expand / collapse

Problem or Use Case

While working on a desktop-notifier plugin I found that Hermes emits no plugin event when the agent invokes the clarify tool. That's exactly the moment a notification is most useful — the agent is blocked waiting for user input — but plugins have no trigger to act on.

Proposed Solution

Add an on_clarify hook that fires when the clarify tool runs, with kwargs matching existing hook conventions (question, choices, session_id, model, platform). Fire it post-validation, so it only triggers when the tool will actually block on a callback, not on malformed calls that immediately error.

Implementation in #12814.

For reference, Claude Code's hook catalogue has a direct analogue (AskUserQuestion). The full comparison is below for context — other gaps are out of scope for this issue, separate follow-ups if there's demand.

<details> <summary>Claude Code ↔ Hermes hook comparison</summary>
Claude Code eventHermes hookStatus
PreToolUsepre_tool_callcovered
PostToolUse / PostToolUseFailurepost_tool_callcovered (no success/failure split)
SessionStarton_session_startcovered
SessionEndon_session_end / on_session_finalize / on_session_resetcovered
AskUserQuestionon_clarifythis issue — #12814
UserPromptSubmitmissing
Stop / StopFailuremissing
SubagentStart / SubagentStopmissing (Hermes has delegate_task but no hook)
Notification (permission_prompt / idle_prompt / …)missing
PreCompact / PostCompactmissing
TaskCreated / TaskCompletedmissing
FileChanged / CwdChanged / InstructionsLoaded / ConfigChangemissing
Elicitation / ElicitationResultmissing (MCP-specific)
WorktreeCreate / WorktreeRemoven/a (no worktree feature in Hermes)
PermissionRequest / PermissionDeniedn/a (no permission layer yet)

Hermes-only hooks, no Claude Code analogue: pre_llm_call, post_llm_call, pre_api_request, post_api_request.

</details>

Alternatives Considered

  • Fire the hook from the agent dispatcher instead of inside the tool. Rejected: duplicates across the concurrent/sequential dispatch paths and fires even for malformed tool calls that will immediately error.
  • Overload pre_tool_call with a tool_name == "clarify" filter. Rejected: every plugin would have to inspect every pre-tool-call to find the ones it cares about; a dedicated hook is discoverable via VALID_HOOKS and keeps handlers single-purpose.

Feature Type

CLI improvement

Scope

Small (single file, < 50 lines) — core change is one hook name + one fire-site; #12814 adds ~150 lines counting the test file.

Contribution

  • I'd like to implement this myself and submit a PR

(#12814)

extent analysis

TL;DR

To address the issue of Hermes not emitting a plugin event when the agent invokes the clarify tool, add an on_clarify hook that fires post-validation, allowing plugins to trigger notifications when the tool blocks on a callback.

Guidance

  • Implement the proposed on_clarify hook in the clarify tool, firing it after validation to ensure it only triggers for valid calls that will block on a callback.
  • Use the existing hook conventions for kwargs, including question, choices, session_id, model, and platform, to maintain consistency with other hooks.
  • Review the comparison with Claude Code's hook catalogue to understand the context and potential future additions.
  • Consider the alternatives rejected in the issue, such as firing the hook from the agent dispatcher or overloading pre_tool_call, to understand the reasoning behind the proposed solution.

Example

No code example is provided as the implementation details are not specified in the issue, but the proposed solution mentions adding an on_clarify hook with specific kwargs.

Notes

The issue is specific to the clarify tool and the proposed solution is a targeted change to add a new hook. The comparison with Claude Code's hook catalogue highlights potential future additions, but these are out of scope for this issue.

Recommendation

Apply the proposed workaround by implementing the on_clarify hook, as it addresses the specific use case and is a targeted change with minimal scope.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING