Skip to main content

Module validate

Module validate 

Source
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: true is set
  • Edit: file exists, old_str is found, old_str is unique (unless replace_all: true), new_str does 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 ToolRegistry and run the standard pre-flight validation against the given root.