Skip to content

Feature: Add tool:pre event for PreToolUse validation hooks #1733

Description

@nixfred

Feature Request: tool:pre Event for PreToolUse Validation Hooks

Target: clawdbot/clawdbot
Status: Draft (needs gh auth to submit)
Authors: Monolith + Larry
Date: 2026-01-25


Summary

Add a tool:pre (or tool:before) event that fires before a tool call is executed, allowing hooks to validate, modify, or block the call.

Motivation

Currently Clawdbot has tool_result_persist (post-tool) but no pre-execution hook. This limits the ability to implement:

  • Safety guards — Block dangerous commands before execution (e.g., rm -rf /, fork bombs)
  • Anti-sycophancy filters — Detect and flag problematic patterns in outbound messages
  • Context thresholds — Warn when context usage exceeds limits
  • Secrets detection — Prevent accidental credential exposure in commands
  • Cross-agent coordination — Validate claims before artifact creation (G10 protocol)

Proposed Event Schema

interface PreToolEvent {
  type: 'tool:pre';
  toolName: string;
  args: Record<string, unknown>;
  sessionKey: string;
  agentId: string;
}

interface PreToolResult {
  action: 'allow' | 'block' | 'modify';
  reason?: string;
  modifiedArgs?: Record<string, unknown>;  // if action === 'modify'
}

Use Cases

1. Dangerous Command Blocking

guards:
  - pattern: 'rm -rf /'
    action: block
    reason: 'Refusing to delete root filesystem'

2. Message Quality Scoring

Before message.send, validate content quality and block low-effort responses.

3. Confirmation Prompts

For destructive operations (git push --force, DROP TABLE), require explicit confirmation.

Prior Art

  • Claude Code has PreToolUse hooks
  • MCP servers can implement tool validation
  • Our prototype: sync/hooks/pre-tool-hook.py in WireParkHackerz/ai-soul-team

Implementation Notes

The event should fire after the LLM returns a tool call but before execution. Hooks should be:

  • Async-capable (for external validation)
  • Chainable (multiple hooks can run in sequence)
  • Fail-safe (hook errors should not block all tool calls)

Related

  • Existing events: command:new, agent:bootstrap, gateway:startup, tool_result_persist
  • Docs: /docs/tools/index.md

To Submit

gh auth login
gh issue create --repo clawdbot/clawdbot --title "Feature: Add tool:pre event for PreToolUse validation hooks" --body-file sync/docs/pretooluse-feature-request.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions