args_valid¶
Validate that tool arguments conform to policy schemas.
Synopsis¶
Description¶
The args_valid metric checks every tool call in a trace against your policy definitions. It validates:
- Argument types (string, number, boolean, etc.)
- Value constraints (min, max, pattern, enum)
- Required fields
- Nested object/array structures
Options¶
| Option | Type | Description |
|---|---|---|
policy | string | Path to policy file |
tools | array | Only validate these tools (optional) |
strict | boolean | Fail on unknown tools (default: false) |
Examples¶
Basic Usage¶
Specific Tools Only¶
tests:
- id: validate_payments
metric: args_valid
policy: policies/payments.yaml
tools:
- process_payment
- refund
- apply_coupon
Inline Policy¶
tests:
- id: discount_check
metric: args_valid
tool: apply_discount
constraints:
percent:
type: number
min: 0
max: 30
Strict Mode¶
tests:
- id: strict_validation
metric: args_valid
policy: policies/known-tools.yaml
strict: true # Fail if trace contains unknown tools
What Gets Checked¶
For each tool call in the trace:
- Is the tool defined? (unless
strict: false) - Are required arguments present?
- Do types match?
- Do values satisfy constraints?
Example Policy¶
tools:
apply_discount:
arguments:
percent:
type: number
min: 0
max: 30
order_id:
type: string
required: true
pattern: "^ord_[0-9]+$"
Example Trace Call¶
Result¶
❌ FAIL: args_valid
Tool: apply_discount
Argument: percent = 50
Violation: Value exceeds maximum (max: 30)
Policy: policies/discounts.yaml:8
Output¶
Pass¶
{
"id": "validate_all",
"metric": "args_valid",
"status": "pass",
"violations": [],
"stats": {
"calls_checked": 47,
"tools_checked": 5
},
"duration_ms": 2
}
Fail¶
{
"id": "validate_all",
"metric": "args_valid",
"status": "fail",
"violations": [
{
"call_index": 15,
"tool": "apply_discount",
"field": "percent",
"value": 50,
"constraint": "max: 30",
"policy_file": "policies/discounts.yaml",
"policy_line": 8
}
],
"stats": {
"calls_checked": 47,
"violations_found": 1
},
"duration_ms": 3
}
Error Messages¶
Assay provides actionable error messages:
❌ FAIL: args_valid (validate_all)
Tool: apply_discount
Call: #15 of 47
Argument: percent = 50
Violation: Value exceeds maximum (max: 30)
Policy: policies/discounts.yaml:8
Suggestion: Use percent <= 30
Trace location: traces/golden.jsonl:29
Common Patterns¶
Type Coercion Issues¶
Fix: Ensure arguments are correct types.
Missing Required Fields¶
Fix: Add the missing argument or update policy.
Pattern Mismatch¶
Fix: Ensure value matches expected format.