run-llama/llama_index · error · ValueError

summaries must be one of ['self', 'prev', 'next']

Error message

summaries must be one of ['self', 'prev', 'next']

What it means

Raised by SummaryExtractor.__init__ when any entry in the summaries list is not one of 'self', 'prev', 'next'. These flags select which node summaries to generate (the node itself, its predecessor, or its successor) and are later used to build metadata keys like node_summary/prev_section_summary/next_section_summary, so unrecognized values fail fast at construction.

Source

Thrown at llama-index-core/llama_index/core/extractors/metadata_extractors.py:395

    )

    _self_summary: bool = PrivateAttr()
    _prev_summary: bool = PrivateAttr()
    _next_summary: bool = PrivateAttr()

    def __init__(
        self,
        llm: Optional[LLM] = None,
        # TODO: llm_predictor arg is deprecated
        llm_predictor: Optional[LLM] = None,
        summaries: List[str] = ["self"],
        prompt_template: str = DEFAULT_SUMMARY_EXTRACT_TEMPLATE,
        num_workers: int = DEFAULT_NUM_WORKERS,
        **kwargs: Any,
    ):
        # validation
        if not all(s in ["self", "prev", "next"] for s in summaries):
            raise ValueError("summaries must be one of ['self', 'prev', 'next']")

        super().__init__(
            llm=llm or llm_predictor or Settings.llm,
            summaries=summaries,
            prompt_template=prompt_template,
            num_workers=num_workers,
            **kwargs,
        )

        self._self_summary = "self" in summaries
        self._prev_summary = "prev" in summaries
        self._next_summary = "next" in summaries

    @classmethod
    def class_name(cls) -> str:
        return "SummaryExtractor"

    async def _agenerate_node_summary(self, node: BaseNode) -> str:

View on GitHub (pinned to afd0fef371)

Solutions

  1. Use only 'self', 'prev', 'next': SummaryExtractor(summaries=['self', 'prev', 'next']).
  2. Normalize config input: summaries = [s.strip().lower() for s in cfg['summaries']] and validate against the allowed set before constructing.
  3. Omit the summaries argument entirely if you only want the default ['self'].

Example fix

# before
extractor = SummaryExtractor(summaries=["self", "previous"])

# after
allowed = {"self", "prev", "next"}
summaries = [s.strip().lower() for s in cfg["summaries"]]
assert set(summaries) <= allowed, f"allowed: {sorted(allowed)}"
extractor = SummaryExtractor(summaries=summaries)
Defensive patterns

Strategy: validation

Validate before calling

ALLOWED = {"self", "prev", "next"}
summaries = [s.strip().lower() for s in config["summaries"]]
invalid = set(summaries) - ALLOWED
if invalid:
    raise ValueError(f"Invalid summary modes {invalid}; allowed: {sorted(ALLOWED)}")
extractor = SummaryExtractor(summaries=summaries)

Type guard

def is_valid_summary_modes(values: list[str]) -> bool:
    return bool(values) and all(v in {"self", "prev", "next"} for v in values)

Prevention

When it happens

Trigger: Constructing SummaryExtractor(summaries=['current']) (wrong vocabulary), summaries=['self ','prev'] (stray whitespace), or summaries=[] piped through a bad mapping step; also non-lowercase variants like 'Prev'.

Common situations: Config-driven pipelines where users write intuitive names ('previous', 'next_section'); string manipulation (split, strip) introducing whitespace/casing; copying example configs from older or newer docs with different accepted values.

Related errors


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