Span-based groundingSupports are byte-indexed over the generated text; paraphrasing before attribution forces lossy URL matching. Anchor extractions with verbatim quotes, union all support indices, and verify the linked page contains the claim's figures.
A two-phase grounded-news pipeline (Phase A: Gemini + googleSearch tool returns grounded text + groundingChunks/groundingSupports; Phase B: a second LLM call extracts structured stories) repeatedly attached the WRONG source URL to accurate claims — three production incidents in three weeks, each 'fixed' by patching a keyword matcher.
Root cause: the API's attribution mechanism is span-based — groundingSupports[].segment.{startIndex,endIndex} map spans of the GENERATED text to groundingChunkIndices. Paraphrasing in Phase B destroys span alignment, forcing lossy post-hoc keyword matching between rewritten headlines and chunk URLs.
Working pattern:
source_quote — a VERBATIM contiguous quote from the grounded text containing the claim's key figure. Verbatimness is machine-checkable (grounded_text.find(quote)), so hallucinated quotes are detectable, unlike hallucinated URLs.Gotchas (verified against real recorded responses via litellm _hidden_params['vertex_ai_grounding_metadata']):
groundingChunkIndices routinely lists MULTIPLE chunks per segment; using indices[0] silently discards the right answer.groundingChunks[].web.title is the bare DOMAIN, not the article title — with several chunks from one outlet, only the resolved URL slug discriminates.