Expand description
Pre-flight validation for tool calls (runs before approval). Pre-flight validation for tool calls.
Runs before the approval prompt so we never ask the user to approve an operation that will inevitably fail. Cheap checks only — no mutations.
§What it validates
- Write: target path resolves within project root
- Write (overwrite): file exists and
overwrite: trueis set - Edit: file exists,
old_stris found,old_stris unique (unlessreplace_all: true),new_strdoes not contain omission placeholders (e.g.// rest of code ...) - Delete: file exists
- Bash: command is non-empty
Validation errors are returned as tool results (not panics), so the model sees the error and can self-correct.
Functions§
- validate_
tool_ call - Validate a tool call before approval.
- validate_
with_ registry - DRY wrapper: pull the three caches from a
ToolRegistryand run the standard pre-flight validation against the given root.