agentvet 0.1.0

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.
Documentation
# agentvet

[![crates.io](https://img.shields.io/crates/v/agentvet.svg)](https://crates.io/crates/agentvet)
[![docs.rs](https://docs.rs/agentvet/badge.svg)](https://docs.rs/agentvet)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)

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.

```toml
[dependencies]
agentvet = "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

```rust
use agentvet::Validator;
use serde_json::json;

// The exact schema you sent in your tool definition:
let schema = json!({
    "type": "object",
    "properties": {
        "city":  {"type": "string"},
        "units": {"type": "string", "enum": ["c", "f"]}
    },
    "required": ["city"],
    "additionalProperties": false
});
let v = Validator::from_schema(&schema).unwrap();

// In your agent loop, before invoking the tool:
let llm_args = json!({"units": "c"});  // model forgot 'city'
match v.validate(&llm_args) {
    Ok(()) => { /* execute the tool */ }
    Err(err) => {
        let hint = err.for_llm();
        // Send `hint` back as the tool result; model self-corrects next turn:
        // > Tool call rejected. Fix and try again:
        // >   - /city: required property missing
    }
}
```

## What you get back

```rust
pub struct ToolArgError { pub issues: Vec<ToolArgIssue> }
pub struct ToolArgIssue { pub pointer: String, pub message: String }
```

`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 `tools` payload).
- Doesn't repair output (different problem; see structured-output libs).

## Sibling: JS `@mukundakatta/agentvet`

JS users: see [@mukundakatta/agentvet](https://www.npmjs.com/package/@mukundakatta/agentvet) on npm.

## License

MIT