Skip to main content

parse_response

Function parse_response 

Source
pub fn parse_response(
    raw: &str,
    candidates: &[&Memory],
) -> Result<SynthesisResponse>
Expand description

Parse a model response into a SynthesisResponse, validating that:

  1. The response decodes as JSON containing the verdicts array.
  2. Every verdict’s candidate_id matches one of the supplied candidate ids (no fabricated ids — Gemma 4 occasionally hallucinates ids when over-eager).
  3. Every verb=update carries non-empty merged_content.
  4. Every supplied candidate id is covered by exactly one verdict.

On any validation failure returns Err; the caller falls back to the legacy code path (a structurally-degraded LLM does NOT block the store).