Example 1: financial calculator agent
Scenario
An AI agent helps users with financial calculations. Need to verify math before returning results.Setup
total = subtotal + tax + shipping - discount, counting any missing part as zero. See what it checks for the other shapes.
Verification
Catching errors
Example 2: blocking dangerous tools
Scenario
Agent has access to shell commands. Need to prevent dangerous operations.Setup
Blocked calls
Allowed calls
Example 3: PII detection
Scenario
Healthcare AI generating patient summaries. Must not leak PII.Setup
PII blocked
custom_patterns entry is an error rather than a warning, so it blocks with any verifier:
Warn instead of block
Example 4: state machine validation
Scenario
Order processing agent. States must follow valid transitions.Setup
new_state in the output. It does not read tool-call arguments, so pass the transition as structured output. Take the current state from your own records and pass it as context["current_state"]. That value wins over any state field in the output, so the agent can’t claim a different starting state to make a transition pass.
Valid transition
Invalid transition (blocked)
Example 5: LangChain integration
Full agent with verification
output, not tool-call arguments, so it would block every tool call with “No verifiable math found in response”. See the LangChain integration for how the callback sees each tool call.
Example 6: budget control
Scenario
Prevent runaway API costs from agent loops.Setup
context["total_cost"] on each check. Any usage.cost the response reports is added to that total. With no cost figure at all, the budget check fails closed.
Budget enforcement
Example 7: argument type validation
Scenario
Ensure tool arguments match expected types.Setup
Validation
Best practices
1. Layer multiple guards
SchemaGuard and MathGuard in a separate stack from tool-call checks. A tool call does not match your output schema and carries no math, so both would fail it.