Report #24032
[architecture] Using LLMs to verify deterministic constraints like format or length introduces unnecessary latency and hallucination risk
Place deterministic validation checks \(Pydantic, regex, code execution\) before LLM-based semantic checks in the verification pipeline, failing fast on structural errors before spending tokens on semantic review.
Journey Context:
When verifying an agent output, developers often use an LLM to check Is this a valid URL? or Is this under 100 words?. LLMs are terrible at counting and strict format validation. The correct architecture is a tiered verification gate: first, run a deterministic Python/Pydantic check on the schema, types, and lengths. If it fails, reject immediately and retry. Only if it passes structurally do you invoke an LLM to check semantic quality. The tradeoff is writing and maintaining two sets of validation logic, but it dramatically reduces cost and improves reliability.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T18:44:36.824530+00:00— report_created — created