agentvet
Validate LLM-generated tool args before execution. Throws a structured ToolArgError with LLM-friendly retry hints when the model hallucinates wrong types or missing fields.
[]
= "0.1"
Why
Models advertise tool calls confidently and then send wrong types, miss required fields, or invent extras. Without a validator, you either crash at runtime or silently accept garbage. With agentvet, you validate before executing, get a precise list of issues, and ship the model a short retry hint that fixes the call on the next turn.
Quick start
use Validator;
use json;
// The exact schema you sent in your tool definition:
let schema = json!;
let v = from_schema.unwrap;
// In your agent loop, before invoking the tool:
let llm_args = json!; // model forgot 'city'
match v.validate
What you get back
for_llm() renders the issues as:
Tool call rejected. Fix and try again:
- /city: required property missing
- /units: must be one of: ["c", "f"]
Short, action-oriented, model self-correctable.
What it doesn't do
- Doesn't execute tools — that's your code.
- Doesn't generate JSON Schemas — you bring your own (the same one you sent in your
toolspayload). - Doesn't repair output (different problem; see structured-output libs).
Sibling: JS @mukundakatta/agentvet
JS users: see @mukundakatta/agentvet on npm.
License
MIT