run-llama/llama_index · error · ValueError

indices and index_summaries must have same length!

Error message

indices and index_summaries must have same length!

What it means

ComposableGraph.from_indices zips children_indices with index_summaries one-to-one. After the summary-setting loop it asserts len(children_indices) == len(index_summaries) and raises ValueError on mismatch. This catches partial summary lists and off-by-one construction errors before corrupt IndexNodes get built.

Source

Thrown at llama-index-core/llama_index/core/indices/composability/graph.py:80

                    if index.index_struct.summary is None:
                        raise ValueError(
                            "Summary must be set for children indices. "
                            "If the index does a summary "
                            "(through index.index_struct.summary), then "
                            "it must be specified with then `index_summaries` "
                            "argument in this function. We will support "
                            "automatically setting the summary in the future."
                        )
                index_summaries = [
                    index.index_struct.summary for index in children_indices
                ]
            else:
                # set summaries for each index
                for index, summary in zip(children_indices, index_summaries):
                    index.index_struct.summary = summary

            if len(children_indices) != len(index_summaries):
                raise ValueError("indices and index_summaries must have same length!")

            # construct index nodes
            index_nodes = []
            for index, summary in zip(children_indices, index_summaries):
                assert isinstance(index.index_struct, IndexStruct)
                index_node = IndexNode(
                    text=summary,
                    index_id=index.index_id,
                    relationships={
                        NodeRelationship.SOURCE: RelatedNodeInfo(
                            node_id=index.index_id, node_type=ObjectType.INDEX
                        )
                    },
                )
                index_nodes.append(index_node)

            # construct root index
            root_index = root_index_cls(

View on GitHub (pinned to afd0fef371)

Solutions

  1. Make summary generation structural: index_summaries = [f'Summary for {i}' for i in sources] derived from the same loop that builds indices.
  2. Add an explicit assert len(indices) == len(index_summaries) before calling from_indices so failures surface with your own context.
  3. Store summaries alongside index configs in one data structure (list of (index, summary) tuples) so they cannot diverge.

Example fix

# before
indices = [sales_idx, hr_idx, legal_idx]
summaries = ["Sales data", "HR policies"]  # 3 vs 2 -> ValueError
graph = ComposableGraph.from_indices(TreeIndex, indices, index_summaries=summaries)

# after
index_defs = [(sales_idx, "Sales data"), (hr_idx, "HR policies"), (legal_idx, "Legal contracts")]
graph = ComposableGraph.from_indices(
    TreeIndex,
    [i for i, _ in index_defs],
    index_summaries=[s for _, s in index_defs],
)
Defensive patterns

Strategy: validation

Validate before calling

assert len(children_indices) == len(index_summaries), (
    f"{len(children_indices)} indices vs {len(index_summaries)} summaries"
)

Prevention

When it happens

Trigger: Passing three child indexes with two index_summaries (or vice versa); generating summaries programmatically where one iteration is skipped; hard-coded summary lists drifting out of sync after adding an index.

Common situations: Maintaining a fixed index_summaries list while adding/removing child indexes over time; mapping/filtering the indices list but forgetting to apply the same transformation to summaries.

Related errors


AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15). Data as JSON: /api/errors/1da8064cd91e078e. Report an issue: GitHub.