openclaw - ✅(Solved) Fix feat: support before_tool_call hooks in local agent mode (--local) [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#65025Fetched 2026-04-12 13:25:56
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
cross-referenced ×1

When running openclaw agent --local, lifecycle hooks registered by plugins (e.g., before_tool_call) do not fire. This means security controls implemented via tool-call hooks are not enforced in local mode.

Root Cause

When running openclaw agent --local, lifecycle hooks registered by plugins (e.g., before_tool_call) do not fire. This means security controls implemented via tool-call hooks are not enforced in local mode.

Fix Action

Fix / Workaround

Ensure the hook dispatch pipeline runs in --local mode the same way it does in gateway mode. If there are performance or architecture reasons to skip hooks in local mode, consider an opt-in flag (e.g., --local --skip-hooks) rather than silently skipping all hooks by default.

PR fix notes

PR #1632: feat(security): block secret writes into persistent workspace memory

Description (problem / solution / changelog)

Summary

  • Registers a before_tool_call plugin hook that blocks write/edit/apply_patch/notebook_edit tool calls to persistent memory paths when secrets are detected
  • 14 high-confidence secret patterns: NVIDIA, OpenAI, Anthropic, GitHub, AWS, Slack, Discord, npm, Telegram, Google, HuggingFace tokens, private keys (PEM), authorization headers
  • Protected paths: .openclaw-data/memory/, workspace/, agents/, skills/, hooks/, MEMORY.md
  • Hook registration wrapped in try/catch so scanner failures cannot break plugin startup
  • Non-memory paths and clean content pass through unchanged

Closes #1233

Test plan

  • 21 unit tests for secret patterns (true positives, false positives, redaction, path matching)
  • 9 integration tests for hook wiring (blocks secrets in memory, allows clean content, allows non-memory paths, handles missing events)
  • TypeScript build passes
  • All 272 plugin tests pass
  • All 954 CLI tests pass
  • gitleaks + detect-private-key hooks pass (test fixtures use runtime-assembled strings)
  • Manual test: verify blocked write shows actionable error in agent session

🤖 Generated with Claude Code

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

Summary by CodeRabbit

  • New Features

    • Automatic secret scanner that blocks write-like operations to persistent memory/workspace paths when high-confidence credentials are detected, returns an actionable block reason, and logs a security warning. Matches are redacted in reports.
  • Documentation

    • Added guidance describing the scanner, covered locations, and observable blocking behavior.
  • Tests

    • Added tests for secret detection, memory-path checks, blocking behavior, and warning logs.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Changed files

  • .agents/skills/nemoclaw-user-configure-security/references/best-practices.md (modified, +21/-0)
  • .agents/skills/nemoclaw-user-overview/SKILL.md (modified, +5/-5)
  • .agents/skills/nemoclaw-user-overview/references/ecosystem.md (modified, +1/-1)
  • .agents/skills/nemoclaw-user-overview/references/overview.md (modified, +3/-3)
  • docs/about/ecosystem.md (modified, +1/-1)
  • docs/about/overview.md (modified, +5/-5)
  • docs/index.md (modified, +5/-5)
  • docs/security/best-practices.md (modified, +21/-0)
  • nemoclaw/src/index.ts (modified, +66/-1)
  • nemoclaw/src/register.test.ts (modified, +142/-0)
  • nemoclaw/src/security/secret-scanner.test.ts (added, +264/-0)
  • nemoclaw/src/security/secret-scanner.ts (added, +136/-0)
  • scripts/nemoclaw-start.sh (modified, +12/-0)
RAW_BUFFERClick to expand / collapse

Summary

When running openclaw agent --local, lifecycle hooks registered by plugins (e.g., before_tool_call) do not fire. This means security controls implemented via tool-call hooks are not enforced in local mode.

Expected Behavior

before_tool_call (and other lifecycle hooks) should fire regardless of whether the agent runs in gateway mode or --local mode. Plugins register hooks to enforce security invariants that should hold in all execution modes.

Proposal

Ensure the hook dispatch pipeline runs in --local mode the same way it does in gateway mode. If there are performance or architecture reasons to skip hooks in local mode, consider an opt-in flag (e.g., --local --skip-hooks) rather than silently skipping all hooks by default.

extent analysis

TL;DR

Modify the openclaw agent --local mode to dispatch lifecycle hooks, such as before_tool_call, to ensure security controls are enforced.

Guidance

  • Review the current implementation of openclaw agent --local to identify why lifecycle hooks are not being dispatched.
  • Consider adding an opt-in flag, such as --skip-hooks, to allow users to choose whether to skip hooks in local mode.
  • Verify that the hook dispatch pipeline is identical in both gateway and local modes to ensure consistent behavior.
  • Investigate potential performance or architecture reasons that may have led to hooks being skipped in local mode.

Example

No code snippet is provided due to lack of implementation details in the issue.

Notes

The solution may require changes to the openclaw agent codebase and should be thoroughly tested to ensure that security controls are properly enforced in all execution modes.

Recommendation

Apply workaround: Modify the openclaw agent --local mode to dispatch lifecycle hooks by default, and consider adding an opt-in flag to skip hooks if necessary, to ensure security controls are enforced consistently across all execution modes.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix feat: support before_tool_call hooks in local agent mode (--local) [1 pull requests, 1 participants]