Expand description
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 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"));Structs§
- Tool
ArgError - Structured error returned when LLM-supplied tool args fail validation.
- Tool
ArgIssue - One concrete schema violation.
- Validator
- Validates JSON values against a JSON Schema.