Files
hermes-agent/agent
Teknium fcc895496e fix(worker): ordinary managed runs register the session's shell hooks and webhooks
Shell hooks and outbound webhooks are callbacks on the process-local plugin manager. The owner
registers them (gateway startup; --accept-hooks consent via accept_launch_hooks), but a managed
turn's tools and model calls run in the worker child, whose plugin manager had none: only the
Kanban path called shell_hooks.register_from_config (bind_worker_context), and no worker ever
registered outbound webhooks. A probe on r6-base recorded 1 shell-hook fire + webhook deliveries
per turn in process and 0/0 for the same turn managed.

gateway/session_policy.register_worker_hooks registers both from the session's frozen config in
the worker, before MCP/tool discovery and agent construction:
- consent = the session's --accept-hooks launch flag (request_json) or the Kanban attempt's
  context (always consents, as before); otherwise register_from_config resolves the usual
  HERMES_ACCEPT_HOOKS / hooks_auto_accept / existing allowlist, with no TTY prompt in the child;
- bypass sessions (config-only/safe) register nothing, matching accept_launch_hooks; the safe
  policy also refuses inside both registrars.
The Kanban-only call in bind_worker_context is folded into this single worker seam (Kanban
workers now also get outbound webhooks, as the classic one-shot CLI worker registered both).

Red/green (tests/gateway/test_managed_worker_hooks.py):
- test_managed_turn_fires_shell_hooks_and_webhooks_in_the_worker (real daemon, loopback model,
  real `sh` hook + loopback webhook receiver, sessions created with accept_hooks=True): against
  the previous commit `'managed': {'shell_pids': [], 'webhooks': []}` vs in-process 1 fire +
  pre_llm_call delivery; green: both fire, and the managed hook's parent pid is the worker, not
  the owner.
- test_worker_hook_registration_follows_the_session_policy: consent sources and bypass refusal.
tests/gateway/test_session_kanban.py stays green.

Review: https://github.com/NousResearch/hermes-agent/pull/106742#pullrequestreview-5462648005
2026-10-08 19:08:59 -07:00
..
…