fix(plugins): bound lifecycle hook execution on hot paths (#10048) - #39751
Open
rodboev wants to merge 3 commits into
Open
fix(plugins): bound lifecycle hook execution on hot paths (#10048)#39751rodboev wants to merge 3 commits into
rodboev wants to merge 3 commits into
Conversation
rodboev
force-pushed
the
pr/plugin-hook-timeouts
branch
from
June 12, 2026 11:38
4ce428c to
f332798
Compare
rodboev
force-pushed
the
pr/plugin-hook-timeouts
branch
from
June 28, 2026 19:57
09b4fcd to
6f0b383
Compare
rodboev
force-pushed
the
pr/plugin-hook-timeouts
branch
3 times, most recently
from
July 7, 2026 04:28
6f0b383 to
ff9a6e7
Compare
teknium1
reviewed
Jul 14, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for tackling a real hot-path reliability issue. The inline dispatcher is still present on current main at hermes_cli/plugins.py:1913-1925, so the premise is valid, but this implementation needs rework before it can provide the stated guarantee.
Problems
hermes_cli/plugins.py:225excludeson_session_startandon_session_end; currentagent/conversation_loop.py:368-373callson_session_startinline. That leaves #10048's concrete lifecycle-hook repro unresolved.hermes_cli/plugins.py:226applies fail-open timeout handling topre_tool_call. Currenthermes_cli/plugins.py:2109-2128documents it as a security/approval policy gate, andresolve_pre_tool_block()is intentionally fail-closed for approval failures at:2244-2268. A timeout must not silently permit the tool call.hermes_cli/plugins.py:2008-2015submits into a four-worker pool and callsfuture.cancel()after timeout. Running futures cannot be cancelled, so several distinct hung callbacks can occupy all workers and starve healthy callbacks;tests/hermes_cli/test_plugins.py:753-795exercises only one hung callback.
Suggested changes
- Add an explicit bounded/background policy for session-boundary hooks and cover the real
on_session_startpath. - Make
pre_tool_calltimeout fail closed, with an end-to-end dispatch test. - Add a saturation test and ensure timed-out running hooks cannot consume every worker.
Automated hermes-sweeper review.
rodboev
force-pushed
the
pr/plugin-hook-timeouts
branch
from
July 14, 2026 03:22
ff9a6e7 to
7c97a2b
Compare
Contributor
Author
|
Thanks, these findings did point to one incomplete execution-policy seam rather than three unrelated call-site fixes.
|
This was referenced Aug 2, 2026
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
Plugin lifecycle hooks run on hot user-turn and tool-dispatch paths, and the earlier timeout salvage still left three holes:
on_session_startandon_session_endwere unbounded,pre_tool_calltimeouts still failed open, and the shared four-worker pool could be starved by distinct hung callbacks.This moves the guarantee into the shared Python callback seam. Bounded hooks now run in isolated per-callback daemon workers with context propagation, session-boundary hooks are covered,
pre_tool_calltimeouts fail closed through the existingresolve_pre_tool_block()path, and observer or transform hooks still fail open after a warning. Hooks that require caller-thread delivery, such assubagent_stop, keep that contract. Shell-hook subprocess timeout behavior is unchanged.Closes #10048.
Reported by @audioh.
Changes
hermes_cli/plugins.py: replace the shared executor path with isolated bounded callback workers, add explicit hook policy groups, coveron_session_startandon_session_end, and return a fail-closed directive for timed or still-runningpre_tool_callcallbacks.tests/hermes_cli/test_plugins.py: add policy-table, saturation, bounded session-hook, and fail-closedpre_tool_callregressions.tests/agent/test_system_prompt_restore.py: cover the real first-turnon_session_startpath under timeout.tests/run_agent/test_run_agent.py: add an end-to-end timedpre_tool_callblock before tool dispatch.Validation
python -m pytest tests\hermes_cli\test_plugins.py tests\agent\test_system_prompt_restore.py tests\run_agent\test_run_agent.py tests\agent\test_plugin_llm.py tests\agent\test_subagent_stop_hook.py -v --timeout=0 --timeout-method=thread— 199 passedruffon changed files — passedgit diff --check— passedTest plan
python -m pytest tests\hermes_cli\test_plugins.py tests\agent\test_system_prompt_restore.py tests\run_agent\test_run_agent.py tests\agent\test_plugin_llm.py tests\agent\test_subagent_stop_hook.py -v --timeout=0 --timeout-method=threadNot in scope
The unrelated
.github/workflows/docker.ymlresidue is excluded from this PR.