fix: register shell hooks in TUI gateway and ACP adapter (issue #41457) - #41464
Open
EdderTalmor wants to merge 1 commit into
Open
fix: register shell hooks in TUI gateway and ACP adapter (issue #41457)#41464EdderTalmor wants to merge 1 commit into
EdderTalmor wants to merge 1 commit into
Conversation
…esearch#41457) Shell hooks (the `hooks:` block in `config.yaml`) were not being registered in the desktop app (TUI gateway) or the ACP adapter (IDE integration) entry paths. This caused `pre_tool_call` block hooks to silently do nothing in those surfaces — a security-relevant gap where configured protections were enforced in CLI/gateway but ignored in desktop/IDE. Root cause: `agent.shell_hooks.register_from_config()` was called at startup in `cli.py`, `hermes_cli/main.py`, and `gateway/run.py`, but not in `tui_gateway/entry.py` or `acp_adapter/session.py`. Fix: Add `register_from_config(load_config(), accept_hooks=False)` calls in both entry points, wrapped in try/except to never block startup. The `accept_hooks=False` matches the gateway pattern since neither surface has a TTY — consent comes from `--accept-hooks`, `HERMES_ACCEPT_HOOKS`, or `hooks_auto_accept: true` in config.
tonydwb
approved these changes
Jun 7, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Register shell hooks at TUI gateway startup and in ACP adapter session creation — two coordinated call-sites, no new abstraction needed.
Highlights
- Both banners explain the consent model (accept_hooks=False -> register_from_config reads env+config) clearly.
except Exception: logger.debug(..., exc_info=True)is a non-blocking, fail-open pattern appropriate for optional hook registration.- TUI uses
load_config()(reads disk); ACP adapter receives config via kwargs — the two call signatures differ, so a shared helper would smuggle in either a config-loader dependency or a passed-by-hand side-effect. The duplication is justified.
No issues.
Reviewed by Hermes Agent
This was referenced Jun 7, 2026
Open
This was referenced Jun 28, 2026
This was referenced Jul 10, 2026
Contributor
|
Thanks for the focused security fix. The reported registration gap remains on current main: Problems
Suggested changes
This is an automated hermes-sweeper review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes issue #41457 — Shell hooks (the
hooks:block inconfig.yaml) were not being registered in the desktop app (TUI gateway) or the ACP adapter (IDE integration) entry paths. This causedpre_tool_callblock hooks to silently do nothing in those surfaces — a security-relevant gap where configured protections were enforced in CLI/gateway but ignored in desktop/IDE.Root Cause
agent.shell_hooks.register_from_config()was called at startup in:cli.py(line 946)hermes_cli/main.py(line 12714)gateway/run.py(line 4503)But was not called in:
tui_gateway/entry.py(desktop app backend)acp_adapter/session.py(IDE integration / ACP adapter)Both surfaces build real
AIAgentinstances and dispatch tools throughhandle_function_call, which does contain thepre_tool_callblock check. The check runs, but the in-process hook registry is empty becauseregister_from_configwas never called — so it finds zero hooks and allows everything.Fix
Added
register_from_config(load_config(), accept_hooks=False)calls in both entry points, wrapped in try/except to never block startup. Theaccept_hooks=Falsematches the gateway pattern since neither surface has a TTY — consent comes from--accept-hooks,HERMES_ACCEPT_HOOKS, orhooks_auto_accept: truein config.Changes
tui_gateway/entry.py: Added shell hook registration after MCP discovery setup, beforegateway.readyeventacp_adapter/session.py: Added shell hook registration in_make_agent()after agent creationVerification
tests/agent/test_shell_hooks.py,tests/agent/test_shell_hooks_consent.py)tests/acp_adapter/)tests/gateway/test_platform_reconnect.py)Related
Closes #41457