feat(plugins): add OpenClaw-style hook lifecycle execution with compatibility aliases#9070
Closed
bugmaker2 wants to merge 2 commits into
Closed
feat(plugins): add OpenClaw-style hook lifecycle execution with compatibility aliases#9070bugmaker2 wants to merge 2 commits into
bugmaker2 wants to merge 2 commits into
Conversation
Introduce canonical plugin hook names with alias compatibility and add modifying/claiming/observe execution paths. Wire new hook phases into tool dispatch, agent lifecycle, and status bar rendering with tests and docs updates. Made-with: Cursor
Contributor
|
The tool-call blocking portion of this PR was merged via #9377 (salvaged from #5385/#4610). The hook renaming, execution patterns (modifying/claiming/observe), model/provider override, and system prompt mutation were not included — the renaming adds backward-compat overhead without clear benefit, and the model/provider override bypasses the resolution chain in ways that would break caching and provider-specific code paths. Individual hooks (on_context_window_update, on_status_bar_render, before_agent_reply) can be added incrementally when concrete consumer plugins exist. Thanks for the comprehensive work! |
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.
What does this PR do?
This PR upgrades Hermes plugin hook orchestration to support canonical lifecycle hook names and explicit execution semantics (modifying, claiming, and observe patterns), while preserving backward compatibility for existing plugins.
It solves two core problems:
This approach keeps old plugins working via alias mapping, while introducing a more structured hook runner model aligned with OpenClaw-style lifecycle phases.
Related Issue
#8642
#8643
#4169
Type of Change
Changes Made
hermes_cli/plugins.py:pre_tool_call->before_tool_callpost_tool_call->after_tool_callpre_llm_call->before_agent_startHookRegistration) inhermes_cli/plugins.py.hermes_cli/plugins.py:invoke_hook_modifying(...)for sequential state mutationinvoke_hook_claiming(...)for first-handledshort-circuitinvoke_hook_observe(...)for fire-and-forget observersbefore_tool_call/after_tool_callinto tool dispatch inmodel_tools.py:before_agent_start,before_agent_reply, andon_context_window_updateinto agent lifecycle inrun_agent.py.on_status_bar_renderinto status text generation incli.pyso plugins can override rendered footer text.website/docs/user-guide/features/hooks.md.tests/hermes_cli/test_plugins.pytests/test_model_tools.pytests/cli/test_cli_status_bar.pyCompatibility Notes
This PR is intentionally backward compatible:
pre_tool_call,post_tool_call,pre_llm_call) continue to work unchanged via alias mapping.invoke_hook(...)remains available.How to Test
uv run python -m pytest tests/hermes_cli/test_plugins.py tests/test_model_tools.py tests/cli/test_cli_status_bar.py -qpre_tool_call) and confirm it still executes.before_tool_callto mutate/block args,before_agent_replyto short-circuit reply,on_status_bar_renderto rewrite status bar text.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Targeted test run:
62 passedfor:tests/hermes_cli/test_plugins.pytests/test_model_tools.pytests/cli/test_cli_status_bar.py