Browse docsshow
Examples
Five realistic verification patterns. Each one is the same call shape — just different prompts, contexts, and verdict sets.
1. Refund classification
A support agent wants to route customer messages. Refund requests need special handling, but customers rarely use the literal word "refund".
tbv.verify(
prompt="Is this customer message a refund request?",
context={"message": customer_text},
allowed_verdicts=["yes", "no"],
confidence_threshold=0.85,
source="support/refund-classifier",
)2. PII leak detection
Before showing an LLM response to an end-user, verify it doesn't contain unmasked personal data.
result = tbv.verify(
prompt="Does this output contain unmasked personally identifiable information?",
context={"output": llm_response},
allowed_verdicts=["clean", "leaked", "borderline"],
confidence_threshold=0.9,
source="agent/pii-guard",
)
if result["final_verdict"] != "clean":
return redact(llm_response)3. Payments fraud screen
Run an LLM-based second-line review on transactions your primary fraud model flagged. Borderline cases route to a human in your fraud-ops team.
tbv.verify(
prompt="Should this transaction be allowed, blocked, or sent for manual review?",
context={
"transaction": {
"card_last4": "8821",
"amount_usd": 4950,
"payee": "new (no prior transactions)",
"location": "Lagos, Nigeria",
"time_since_login_minutes": 3,
},
"cardholder_baseline": {
"typical_amount_usd": "50-500",
"typical_payees": "known/recurring",
},
},
allowed_verdicts=["allow", "block", "review"],
confidence_threshold=0.9,
source="payments/fraud-secondline",
)4. Tool-call validation
Before executing a tool an agent picked, verify it's the right tool with valid arguments. Catches the "agent confused refund with cancel" class of bug.
tbv.verify(
prompt="Did the agent invoke the correct tool with valid arguments for the user's request?",
context={
"user_request": user_message,
"tool_called": chosen_tool,
"tool_args": chosen_args,
"tools_available": list(available_tools.keys()),
},
allowed_verdicts=["correct", "wrong_tool", "invalid_args"],
confidence_threshold=0.9,
source="agent/tool-call-validator",
)5. Decorator / wrapper pattern
Wrap your existing classifier so verification runs automatically. The wrapped function is your existing primary; the decorator forwards its return value AND submits a verification.
from tobeverified import verified
@verified(
allowed_verdicts=["safe", "unsafe", "needs_review"],
confidence_threshold=0.9,
source="my-app/comment-mod",
)
def moderate(text: str) -> dict:
# Build the verification payload
return {
"prompt": "Is this comment safe to publish?",
"context": {"text": text},
}
result = moderate("user-supplied content")
# result.verdict, result.tier, result.output