1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! Validate LLM-generated tool args before execution.
//!
//! When an LLM emits a tool call, the arguments may have wrong types,
//! missing required fields, or extra fields. `agentvet` validates them
//! against the same JSON Schema you sent the model and returns a
//! [`ToolArgError`] whose [`for_llm`](ToolArgError::for_llm) renders a
//! short human-readable hint you can feed back to the model on the next
//! turn so it can self-correct.
//!
//! # Quick start
//!
//! ```
//! use agentvet::{ToolArgError, Validator};
//! use serde_json::json;
//!
//! // The same JSON Schema you advertised 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();
//!
//! // Good args: validation passes.
//! v.validate(&json!({"city": "SFO", "units": "c"})).unwrap();
//!
//! // Bad args: structured error with an LLM-friendly retry hint.
//! let err = v.validate(&json!({"units": "c"})).unwrap_err();
//! assert!(err.for_llm().contains("city"));
//! ```
pub use crate;
pub use crateValidator;