Skip to content

Connected image chunks silently dropped in assemble_retrieval_results #206

Description

@EricNGOntos

Problem

In packages/shared-python/shared/services/retrieval/hydration/result_assembly.py, image chunks referenced by text chunks via connect_to metadata are silently dropped from retrieval results.

Root Cause

  1. Line 46-50: All chunks referenced via connect_to are marked as embedded_targets and excluded from the final results list (line 54: if row.get('chunk_id') in embedded_targets: continue)

  2. Line 71: When assembling text chunk content, only table type targets are inlined:

    if normalize_chunk_type(target_row.get('chunk_type')) != 'table':
        continue  # images are skipped here

This means connected images are:

  • Excluded from the results array (treated as "embedded")
  • Never actually embedded/inlined into the parent text content

Impact

  • Affected paths: _run_classic_topk_route (new) and _try_run_small_corpus_route (existing, runs in production daily)
  • Not affected: Agentic route — the evidence renderer (agentic/evidence/renderer.py) has its own image handling that correctly inlines [Image: {asset_url}]\n{description}
  • Standalone image chunks (not referenced by any text via connect_to) are unaffected — they appear in results with correct asset_url

Suggested Fix

In assemble_retrieval_results, when processing text chunks' connected targets, add handling for image type alongside table:

if normalize_chunk_type(target_row.get('chunk_type')) == 'table':
    # existing table summary logic
elif normalize_chunk_type(target_row.get('chunk_type')) == 'image':
    # inline image reference: [Image: {asset_url or file_path}]\n{description}

Alternatively, exclude image chunks from embedded_targets so they appear as standalone results with their own asset_url.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions