Repository navigation
Description
Summary
After upgrading a long-running install from 2026.5.27 → 2026.6.5, before_tool_call / after_tool_call hooks of local (global-dir) extensions register successfully but never fire during agent runs. Hook-based safety/observability plugins (an approval gate on before_tool_call, a tool-call logger on after_tool_call) silently stop working. Rolling back to 2026.5.27 (same configs, same manifests) restores hook firing.
Environment
- openclaw 2026.6.5 (5181e4f), upgraded from 2026.5.27 (27ae826)
- Node v22.22.0 (nvm), Ubuntu 24.04
- Extensions in
~/.openclaw/extensions/<name>/withopenclaw.plugin.jsonmanifests, enabled viaplugins.allow+plugins.entries.<name>.enabled: true openclaw doctor --fixran clean after upgrade (legacyagentRuntimekeys +openai-codex-responsesapi migrated)
Repro
- Extension registering a blocking hook:
export default function register(api) { api.logger.info('[gate] registered'); api.on('before_tool_call', (event) => { if ((event.params?.command || '').includes('curl')) { return { block: true, blockReason: 'blocked by gate' }; } }); }
- On 2026.5.27: agent run attempting
curl -X POST …→ blocked, blockReason returned to the model. ✅ - On 2026.6.5: same run → command executes, hook handler never invoked. ❌ Registration log line appears (both at gateway boot and at run start), but the handler does not run. An
after_tool_calllogger plugin shows the same: registration logged, zero events captured.
Verified through both an openclaw agent --agent … --message … run and a normal channel-originated embedded run.
What we tried
- Added
activation.onCapabilities: ["hook"]to all extension manifests → plugins now load at gateway boot (visible in the "http server listening (N plugins: …)" line) instead of lazily, registration logs appear — hooks still never fire. - Added explicit per-plugin hook policy in config (
plugins.entries.<name>.hooks.timeouts.before_tool_call) → no change. openclaw plugins registry --refresh→ no change.- Interesting data point: a
before_prompt_buildhook (withhooks.timeoutsconfigured) does fire on 6.5. The breakage seems specific to the tool-call hook path for these plugins. - During state migration, doctor logged:
Left plugin install index in place because shared SQLite state has conflicting plugin install metadata for: …(3 stock plugins) — possibly related, possibly noise.
In dist/agent-tools.before-tool-call-*.js the path is gated by getGlobalHookRunner()?.hasHooks("before_tool_call") — it looks like the runtime hook registrations from these plugins don't land in (or aren't visible to) the runner instance consulted there.
Expected
before_tool_call/after_tool_call handlers of enabled local extensions fire in agent runs, as on 2026.5.27 — or, if extra activation/permission config is now required, a doctor warning + docs note saying so.
Workaround
Pinned to 2026.5.27.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 10, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 15, 2026, 1:18 PM ET / 17:18 UTC.
Summary
Keep this open: current main and the latest release still contain the single/global hook-runner visibility split, while the proof-positive fix remains an open unmerged PR. The issue is security-relevant because a registered local
before_tool_callgate can be skipped before native tool execution.Reproducibility: yes. at source level with high confidence. Current main preserves a gateway-bound global runner across a later default activation, and tool execution asks only that runner whether
before_tool_callhooks exist.Next step
Do not queue a new automated fix PR because #92016 already owns the implementation path and the issue is security-sensitive.
Security
Needs attention: This issue is security-sensitive because a local fail-closed tool-call gate can be registered but skipped at execution time.
Review details
Best possible solution:
Land #92016 or an equivalent core plugin-runtime fix that makes tool-call dispatch see the canonical live hook registry without requiring new activation or timeout configuration.
Do we have a high-confidence way to reproduce the issue?
Yes, at source level with high confidence. Current main preserves a gateway-bound global runner across a later default activation, and tool execution asks only that runner whether
before_tool_callhooks exist.Is this the best way to solve the issue?
Yes, the best path is to fix hook-registry lifecycle ownership rather than add activation, timeout, or permission configuration. The open linked PR targets that owner boundary, but this issue should remain open until that work is merged or replaced.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
before_tool_callpolicy hooks remain invisible to tool execution.after_tool_callcan silently miss the same tool events through the global-runner split.Codex review notes: model internal, reasoning high; reviewed against 8ded75628437.
Label changes
Label changes:
clawsweeper:linked-pr-open: Current issue advisory state no longer selects this label.Label justifications:
P1: This is a stable-release regression that can silently disable safety and observability hooks during normal agent tool execution.impact:security: A configuredbefore_tool_callgate can stop enforcing the tool-execution boundary while commands continue to run.Evidence reviewed
Security concerns:
src/agents/agent-tools.before-tool-call.ts:1041The global runner consulted by
runBeforeToolCallHook()can lack the active plugin registry'sbefore_tool_callhandler, so native tool execution can proceed without the configured block or approval decision.Confidence: 0.93
What I checked:
HookRunnerover the passed registry and storing that exact runner globally; it does not compose live active or pinned registries. (src/plugins/hook-runner-global.ts:32, 8ded75628437)activatePluginRegistrystill preserves the existing gateway hook runner when a later default-mode activation occurs, then sets the active registry without reinitializing the global runner. (src/plugins/loader.ts:1712, 8ded75628437)src/plugins/loader.test.ts:4104, 8ded75628437)runBeforeToolCallHookcallsgetGlobalHookRunner()and returns early when that runner reports nobefore_tool_callhooks, matching the silent-bypass shape in the report. (src/agents/agent-tools.before-tool-call.ts:1041, 8ded75628437)getGlobalHookRunner()before firingafter_tool_call, which supports the report that both tool-hook directions can disappear through the same runner visibility split. (src/agents/embedded-agent-subscribe.handlers.tools.ts:1669, 8ded75628437)v2026.6.6points at 8c802aa and still contains the samepreserveGatewayHookRunnerbranch, so the fix is not shipped in the latest release. (src/plugins/loader.ts:1708, 8c802aa68351)Likely related people:
src/plugins/hook-runner-global.ts,src/plugins/runtime.ts,src/plugins/loader.ts)src/plugins/runtime.ts,src/plugins/hook-runner-global.ts,src/plugins/loader.ts)before_tool_callinto tool execution, which is the contract this regression breaks. (role: introduced before-tool-call execution wiring; confidence: medium; commits: 8eb11bd3044a; files:src/agents/pi-tools.before-tool-call.ts,src/agents/agent-tools.before-tool-call.ts)src/plugins/loader.ts,src/plugins/hook-runner-global.ts,src/agents/agent-tools.before-tool-call.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.juno02139 commentedon Jun 16, 2026
Still present in the latest release
v2026.6.6— with a security-boundary impactConfirming this regression is live in
v2026.6.6(8c802aa) and that it defeats a real tenant-isolation control, in support of #92016.Setup: an in-tree plugin registers a
before_tool_callhook that returns a block for tool calls whosesessionKeyoriginates from an untrusted Discord channel (a per-channel tool gate).register()runs once at boot (trustedChannels=15 blockAllTools=true); the sister plugin'safter_tool_callfires normally.Symptom: on
v2026.6.6, a Discord channel-origin nativeexecruns un-gated — thebefore_tool_callhandler is never invoked (no plugin log line for the turn, no block), so the gate is silently bypassed. Onv2026.6.5(5181e4f) the identical call is blocked as designed. So the runner/registry split this issue describes is still shipping in the latest release, and its practical effect here is that a plugin-enforced tenant wall fails open — an untrusted channel can execute native tools.Repro (live, 2026-06-15):
@bot run \date`from an untrusted Discord channel →v2026.6.6returned a fresh real date with no block;v2026.6.5returned the cached value with an explicit "blocked" caveat + a block-audit event. We've pinned back tov2026.6.5` pending #92016.fix(plugins): compose live hook registry view for tool-call hooks
fix(plugins): compose live hook registry view for tool-call hooks
fix(plugins): compose live hook registry view for tool-call hooks
fix(plugins): compose live hook registry view for tool-call hooks
chore: upstream sync openclaw -> gemmaclaw 2026-06-18 (batch 3)