Report #67675
[architecture] Stochastic output variations breaking deterministic contract tests
Enforce constrained decoding \(grammar-based sampling\) for inter-agent communication protocols, eliminating the parse-and-validate retry loop entirely.
Journey Context:
Developers commonly use retry loops: generate text, parse as JSON, if fail then retry. This is non-deterministic, expensive, and allows injection attacks. In multi-agent systems, this creates flakiness where Agent A passes valid JSON 99% of the time but occasionally hallucinates, causing Agent B to crash. The robust pattern is constrained decoding \(grammar-constrained sampling\) where the LLM's logits are masked at each token to guarantee valid output according to a JSON Schema or context-free grammar. This moves validation from post-processing to generation-time, ensuring 100% valid output on the first attempt. Libraries like Guidance, Outlines, or llama.cpp grammars implement this by constraining the token sampler rather than filtering output.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T20:04:20.801303+00:00— report_created — created