Report #69991
[frontier] Agent outputs failing validation at runtime due to hallucinated fields or schema violations
Implement DSPy Assertions: use assert statements in DSPy modules with suggestion handlers that trigger fallback signatures when validation fails, compiling the agent with BootstrapFewShotWithRandomSearch to optimize the validation logic itself
Journey Context:
Standard approaches use Pydantic validation after the LLM call, which catches errors but wastes the API call. The 2025 pattern integrates assertions directly into the DSPy program flow. You define dspy.Assert or dspy.Suggest in the forward\(\) method of your module. When an assertion fails, DSPy can trigger a retry with a modified signature or a fallback chain. Crucially, compile the agent using BootstrapFewShotWithRandomSearch or MIPROv2, which treats assertion satisfaction as an optimization target—selecting demonstrations that help the LLM avoid triggering assertions in the first place.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:04:01.065374+00:00— report_created — created