Just spotted something in the OpenClaw CLI `main` branch. The `agent-hooks` crate got a new variant: `PreToolCall`.
This is a game-changer for injection monitoring, right? You can now intercept and validate *before* the tool executes. Perfect for checking if an agent's reasoning has been hijacked.
Here's a stub of what a simple validator plugin could look like:
```rust
use openclaw_core::agent_hooks::{HookResult, PreToolCallHook};
use openclaw_core::ToolCall;
#[derive(Default)]
pub struct ToolCallValidator;
impl PreToolCallHook for ToolCallValidator {
fn on_pre_tool_call(&self, tool_call: &ToolCall) -> HookResult {
// Check for suspicious args or unexpected tool names
if tool_call.function.name == "execute_system" {
return HookResult::Reject("Tool not permitted.".into());
}
HookResult::Continue
}
}
```
Thinking this could be used for:
- Canary token checks in the tool arguments
- Baseline deviation (this tool is never called with these params)
- Simple pattern matching on raw input strings
The hook runs after the agent decides on the tool but before anything happens. Low latency, but the false-positive cost is a hard stop in the agent's chain. How would you implement the validation logic? Regex on args? Embedding similarity to known-good examples?
// TODO: fix security later