fix(cli): register shell hooks in hermes serve sessions by adding 'serve' to _AGENT_COMMANDS (#61806) - #61844
Conversation
…ve to _AGENT_COMMANDS
Related: #61806 (the issue this fixes), and competing fix PRs #57020 and #61823 for the same desktop/serve shell-hook gap. This PR takes the narrowest approach (add |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for isolating the current-main gate: serve is indeed absent from _AGENT_COMMANDS at hermes_cli/main.py:12383, so _prepare_agent_startup() returns before register_from_config().
Problems
- The added
serveentry only covers the launch-profile, in-process server.dashboardshares the samecmd_dashboardhandler but remains outside_AGENT_COMMANDS; profile-scoped dashboard chats deliberately spawntui_gateway.entryrather than attach to the in-process gateway (hermes_cli/web_server.py:14544-14547). Those paths still do not pass through this gate. tests/hermes_cli/test_serve_command.pyhas parser/headless contracts only; it does not verify configured hook registration orpre_tool_callblocking.
Suggested changes
- Re-scope registration to the agent-construction paths with explicit profile-aware behavior, covering both in-process and spawned TUI sessions.
- Add regression coverage that proves an allowlisted blocking hook fires on both paths.
Automated hermes-sweeper review.
| @@ -12384,7 +12384,7 @@ def _plugin_cli_discovery_needed() -> bool: | |||
| return True | |||
There was a problem hiding this comment.
serve covers only the launch-profile in-process path. dashboard shares the handler but remains excluded, while profile-scoped dashboard chats spawn tui_gateway.entry and never reach this gate (hermes_cli/web_server.py:14544-14547). Please register at the agent-construction path(s) with profile-aware coverage instead.
…ousResearch#102504) Consolidate dashboard/serve runtime hook registration into topical `hermes_cli/config_shell_hooks.py` following the main.py decomposition. Ensures deterministic plugin-first ordering after synchronous plugin discovery, preserves hook-free contracts for early lifecycle exits (--status / --stop), and includes real-path precedence test coverage. Co-authored-by: NousResearch#61844 <contributor@nousresearch.com> Co-authored-by: NousResearch#70461 <contributor@nousresearch.com> Co-authored-by: NousResearch#69832 <contributor@nousresearch.com> Co-authored-by: NousResearch#102513 <contributor@nousresearch.com> Co-authored-by: NousResearch#81409 <contributor@nousresearch.com>
Summary
Shell hooks (pre_tool_call) were never registered in
hermes servesessions, allowing Desktop app / dashboard API sessions to bypass all hook policies.Root Cause
_prepare_agent_startup()gates shell hook registration onargs.command in _AGENT_COMMANDS."serve"was missing from that set, so serve sessions never calledagent.shell_hooks.register_from_config().Change
Added
"serve"to_AGENT_COMMANDSinhermes_cli/main.py.Verification
731 serve-related tests pass.