fix(plugins): bound hook execution and retire stale registrations (#115695)

* fix(plugins): bound hooks and own legacy registrations

* docs(hooks): clarify internal handler ownership

* fix(cli): retain message hook shutdown deadline
This commit is contained in:
Vincent Koc
2026-07-29 16:44:05 +08:00
committed by GitHub
parent 0f9c702d8b
commit 80707db7ab
11 changed files with 329 additions and 40 deletions
+2
View File
@@ -27,6 +27,8 @@ OpenClaw has several extension surfaces that look similar but solve different pr
Use internal hooks when you want automation that behaves like a small installed integration. Use typed plugin hooks when you need runtime lifecycle control.
Internal hook handlers are request/event handlers. They must not own long-lived timers, watchers, sockets, or clients; plugins should register a service or use the typed `gateway_start` / `gateway_stop` lifecycle instead.
## Quick start
```bash
+8
View File
@@ -93,6 +93,14 @@ receive a cancellation signal. The hook dispatch can release its Gateway
admission while that plugin work is still in progress. Plugins that own
long-running work must provide their own cancellation and shutdown lifecycle.
Policy hooks `before_tool_call` and `before_install` use a 15-second default per
handler. A timeout fails closed: the tool call or installation is rejected
instead of continuing without a policy decision.
`gateway_stop` uses a five-second default per handler. Timed-out handlers are
logged and shutdown continues so plugin cleanup cannot consume the Gateway
process watchdog.
Outbound modifying hooks `message_sending` and `reply_payload_sending` use a
15-second default per handler. If one times out, OpenClaw logs the plugin error
and continues with the latest payload so the serialized delivery lane can