0005 No-answer guarantee: deterministic on JSON, contract-based on streaming¶
Status¶
Accepted
Context¶
Sources used to be resolved before generation began, so zero surviving sources meant zero LLM calls on either delivery path. Under the current architecture (ADR 0001), retrieval happens inside the agent's streaming call itself: tokens may already be in flight before the final source count is known, and a partially streamed response cannot be retracted.
Decision¶
- The JSON delivery path returns the configured no-answer message deterministically whenever no sources survive filtering.
- The SSE delivery path has no equivalent hard gate. It relies on the system prompt's built-in citation contract, which instructs the model to say it lacks sources rather than answer from outside knowledge.
Consequences¶
- Rejected alternative: buffering the entire stream before releasing any tokens. This kills perceived latency, and deadlocks in the legitimate case where the agent answers a follow-up straight from conversation history without retrieving anything new (see ADR 0006).
- Streaming answer quality on a no-sources turn depends on the model reliably honoring the citation contract, not on a code-level guarantee.