Skip to content

fix(cli): register shell hooks in hermes serve sessions by adding 'serve' to _AGENT_COMMANDS (#61806) - #61844

Open
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/61806-shell-hooks-serve
Open

fix(cli): register shell hooks in hermes serve sessions by adding 'serve' to _AGENT_COMMANDS (#61806)#61844
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/61806-shell-hooks-serve

Conversation

@webtecnica

Copy link
Copy Markdown
Contributor

Summary

Shell hooks (pre_tool_call) were never registered in hermes serve sessions, allowing Desktop app / dashboard API sessions to bypass all hook policies.

Root Cause

_prepare_agent_startup() gates shell hook registration on args.command in _AGENT_COMMANDS. "serve" was missing from that set, so serve sessions never called agent.shell_hooks.register_from_config().

Change

Added "serve" to _AGENT_COMMANDS in hermes_cli/main.py.

Verification

731 serve-related tests pass.

@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard comp/dashboard Web dashboard / control panel UI (dashboard/, landing) sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data P2 Medium — degraded but workaround exists labels Jul 10, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

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 serve to _AGENT_COMMANDS so _prepare_agent_startup registers config hooks); #57020 registers at the tui_gateway._make_agent chokepoint (covers the serve in-memory path + has tests) and #61823 wires both entry.py and server.py. All three are open and address the same gap via different mechanisms -- a maintainer should pick the canonical one.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 serve entry only covers the launch-profile, in-process server. dashboard shares the same cmd_dashboard handler but remains outside _AGENT_COMMANDS; profile-scoped dashboard chats deliberately spawn tui_gateway.entry rather 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.py has parser/headless contracts only; it does not verify configured hook registration or pre_tool_call blocking.

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.

Comment thread hermes_cli/main.py
@@ -12384,7 +12384,7 @@ def _plugin_cli_discovery_needed() -> bool:
return True

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@teknium1 teknium1 added the sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform label Jul 11, 2026
@teknium1 teknium1 added the area/sessions Session lifecycle, resume, persistence, history label Jul 19, 2026
ericmaddox added a commit to ericmaddox/hermes-agent that referenced this pull request Sep 5, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sessions Session lifecycle, resume, persistence, history comp/cli CLI entry point, hermes_cli/, setup wizard comp/dashboard Web dashboard / control panel UI (dashboard/, landing) P2 Medium — degraded but workaround exists sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants