Skip to content

[Bug]: Plugin-registered internal hooks are cleared during gateway startup#13709

Closed
ramarnat wants to merge 1608 commits intoopenclaw:mainfrom
locusai:pr/internal-hooks-clear-before-plugins
Closed

[Bug]: Plugin-registered internal hooks are cleared during gateway startup#13709
ramarnat wants to merge 1608 commits intoopenclaw:mainfrom
locusai:pr/internal-hooks-clear-before-plugins

Conversation

@ramarnat
Copy link
Copy Markdown

@ramarnat ramarnat commented Feb 10, 2026

Summary

Plugins that register internal hooks during plugin registration (e.g. session:start) lose those hooks when the gateway later loads file-based hooks. The gateway clears internal hooks during startup after plugin registration, wiping plugin-registered hooks.

Steps to reproduce

  1. Create/enable a plugin that registers an internal hook in its registration step (e.g. session:start).
  2. Configure any workspace/internal hooks so loadInternalHooks(...) runs during startup.
  3. Start the gateway.

Expected behavior

Plugin-registered internal hooks should remain registered after internal hooks are loaded.

Actual behavior

Plugin-registered internal hooks are cleared and do not fire.

Environment

  • Clawdbot version: 2026.2.9
  • OS: Linux
  • Install method: Docker

Notes / Why

The gateway clears internal hooks during startGatewaySidecars after plugin registration. Fix is to clear before plugins register hooks and keep hook discovery additive. (Branch: pr/internal-hooks-clear-before-plugins includes fix + regression test.)

Greptile Overview

Greptile Summary

This PR fixes a bug where plugins that registered internal hooks during initialization (e.g., session:start) would lose those hooks when the gateway later loaded file-based hooks. The root cause was that clearInternalHooks() was being called in startGatewaySidecars after plugins had already registered their hooks.

Key Changes:

  • Moved clearInternalHooks() call from server-startup.ts:99 (after plugins load) to server.impl.ts:234 (before plugins load)
  • Updated comments to clarify that internal hooks should only be cleared once at startup, before plugin registration
  • Added comprehensive regression test that verifies plugin-registered internal hooks survive the loadInternalHooks() call

How it works:

  1. Gateway startup clears internal hooks registry once (server.impl.ts:234)
  2. Plugins are loaded and may register internal hooks via api.registerHook() (server.impl.ts:235)
  3. Later, startGatewaySidecars() loads file-based hooks additively without clearing (server-startup.ts:101)
  4. Both plugin-registered and file-based hooks coexist in the registry

The fix ensures hook discovery is additive rather than destructive, preserving all hooks regardless of registration source.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix is surgical and well-reasoned: it moves a single function call to the correct location in the startup sequence. The change is backed by a comprehensive regression test that validates the exact bug scenario described. The execution order is clear (clear hooks → load plugins → load file hooks), and the comments explain the rationale. No breaking changes or risky refactoring involved.
  • No files require special attention

(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!

steipete and others added 28 commits February 18, 2026 04:53
…claw#18660)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: ba54c5a
Co-authored-by: robbyczgw-cla <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
…openclaw#19609)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 10d9df5
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

27 similar comments
@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

ramarnat added a commit to locusai/openclaw that referenced this pull request Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: android App: android app: ios App: ios app: macos App: macos app: web-ui App: web-ui channel: bluebubbles Channel integration: bluebubbles channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: irc channel: line Channel integration: line channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: tlon Channel integration: tlon channel: twitch Channel integration: twitch channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser cli CLI command changes commands Command implementations docker Docker and sandbox tooling docs Improvements or additions to documentation extensions: copilot-proxy Extension: copilot-proxy extensions: device-pair extensions: diagnostics-otel Extension: diagnostics-otel extensions: google-antigravity-auth Extension: google-antigravity-auth extensions: google-gemini-cli-auth Extension: google-gemini-cli-auth extensions: llm-task Extension: llm-task extensions: lobster Extension: lobster extensions: memory-core Extension: memory-core extensions: memory-lancedb Extension: memory-lancedb extensions: minimax-portal-auth extensions: open-prose Extension: open-prose extensions: phone-control gateway Gateway runtime scripts Repository scripts security Security documentation size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants