fix: preserve structuredDocumentInfo/unstructuredDocumentInfo references in GoogleConversationalSearchTracer#37
Merged
viniciusdsmello merged 1 commit intoJul 6, 2026
Conversation
…ocumentInfo references extract_references only handled the chunk_info variant of Answer.Reference's 3-way content oneof, silently dropping references that use structured_document_info or unstructured_document_info. Dispatch over all three variants instead, and add regression tests for each (plus the mixed and no-known-variant cases). Fixes #35
29fd8c6 to
f50a5f5
Compare
whoseoyster
approved these changes
Jul 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GoogleConversationalSearchTracer#extract_referencesonly handled thechunk_infovariant ofAnswer.Reference.content(a 3-way protobufoneof), silently dropping references that usestructured_document_infoorunstructured_document_infovianext nil if chunk_info.nil?+.compact.contentoneof variants now.structured_document_infomapsdocument/uri/title/struct_data;unstructured_document_infomapsdocument/uri/titlepluscontentjoined from itschunk_contents.metadata[:references_count](raw count) could disagree with the actually-tracedreferences(previously silently truncated).Fixes #35
Why
traced_contextcorrectly stays 0 for structured docsA
structured_document_inforeference carries no free-text — only structured JSON (struct_data) — so it populatesreferencesbut intentionally contributes nothing to the RAGcontextarray. That's not a partial fix; there's no prose to surface.struct_dataitself is preserved on the reference.Verification
mainbefore the fix (traced_references: 0) and confirmed it now returnstraced_references: 1.googleapis/googleapis: google/cloud/discoveryengine/v1/answer.proto) —StructuredDocumentInfofields are exactlydocument,struct_data,title,uri.chunk_info(characterizes pre-existing behavior),structured_document_info,unstructured_document_info, mixed variants, no-known-variant (doesn't raise), andreferences_countmetadata consistency.rubocop/steep/srb typecheckall clean on the touched files (3 pre-existingLayout/LineLengthoffenses elsewhere in the file are untouched by this change).Test plan
bundle exec rake test TEST=test/openlayer/integrations/google_conversational_search_tracer_test.rb— 6 runs, 21 assertions, 0 failuresbundle exec rake test(full suite) — same pre-existing 31 mock-server connection errors as onmain(documented in CONTRIBUTING.md as needing./scripts/mock), 0 new failuresbundle exec rake lint— clean