Skip to content

fix: preserve structuredDocumentInfo/unstructuredDocumentInfo references in GoogleConversationalSearchTracer#37

Merged
viniciusdsmello merged 1 commit into
mainfrom
vini/open-11598-fix-structured-document-info-references
Jul 6, 2026
Merged

fix: preserve structuredDocumentInfo/unstructuredDocumentInfo references in GoogleConversationalSearchTracer#37
viniciusdsmello merged 1 commit into
mainfrom
vini/open-11598-fix-structured-document-info-references

Conversation

@viniciusdsmello

Copy link
Copy Markdown
Contributor

Summary

  • GoogleConversationalSearchTracer#extract_references only handled the chunk_info variant of Answer.Reference.content (a 3-way protobuf oneof), silently dropping references that use structured_document_info or unstructured_document_info via next nil if chunk_info.nil? + .compact.
  • Dispatches over all three content oneof variants now. structured_document_info maps document/uri/title/struct_data; unstructured_document_info maps document/uri/title plus content joined from its chunk_contents.
  • As a side effect, this also fixes the internal inconsistency where metadata[:references_count] (raw count) could disagree with the actually-traced references (previously silently truncated).

Fixes #35

Why traced_context correctly stays 0 for structured docs

A structured_document_info reference carries no free-text — only structured JSON (struct_data) — so it populates references but intentionally contributes nothing to the RAG context array. That's not a partial fix; there's no prose to surface. struct_data itself is preserved on the reference.

Verification

  • Reproduced the issue's exact offline repro against main before the fix (traced_references: 0) and confirmed it now returns traced_references: 1.
  • Cross-checked field mappings against the upstream proto (googleapis/googleapis: google/cloud/discoveryengine/v1/answer.proto) — StructuredDocumentInfo fields are exactly document, struct_data, title, uri.
  • Added regression tests via TDD (one RED→GREEN cycle per variant): chunk_info (characterizes pre-existing behavior), structured_document_info, unstructured_document_info, mixed variants, no-known-variant (doesn't raise), and references_count metadata consistency.
  • rubocop/steep/srb typecheck all clean on the touched files (3 pre-existing Layout/LineLength offenses 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 failures
  • bundle exec rake test (full suite) — same pre-existing 31 mock-server connection errors as on main (documented in CONTRIBUTING.md as needing ./scripts/mock), 0 new failures
  • bundle exec rake lint — clean

@viniciusdsmello viniciusdsmello self-assigned this Jul 6, 2026
…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
@viniciusdsmello viniciusdsmello force-pushed the vini/open-11598-fix-structured-document-info-references branch from 29fd8c6 to f50a5f5 Compare July 6, 2026 14:35
@viniciusdsmello viniciusdsmello merged commit 7790640 into main Jul 6, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Google conversational search tracer drops structuredDocumentInfo references from AnswerQueryResponse

2 participants