run-llama/llama_index · error · ValueError

Invalid mode: {mode}

Error message

Invalid mode: {mode}

What it means

Error "Invalid mode: {mode}" thrown in run-llama/llama_index.

Source

Thrown at llama-index-core/llama_index/core/postprocessor/node.py:360

                query_str=query_bundle.query_str,
            )
            raw_pred = cast(str, raw_pred)
            mode = self._parse_prediction(raw_pred)

            logger.debug(f"> Postprocessor Predicted mode: {mode}")
            if self.verbose:
                print(f"> Postprocessor Predicted mode: {mode}")

            if mode == "next":
                all_nodes.update(get_forward_nodes(node, self.num_nodes, self.docstore))
            elif mode == "previous":
                all_nodes.update(
                    get_backward_nodes(node, self.num_nodes, self.docstore)
                )
            elif mode == "none":
                pass
            else:
                raise ValueError(f"Invalid mode: {mode}")

        sorted_nodes = sorted(all_nodes.values(), key=lambda x: x.node.node_id)
        return list(sorted_nodes)


class LongContextReorder(BaseNodePostprocessor):
    """
    Models struggle to access significant details found
    in the center of extended contexts. A study
    (https://arxiv.org/abs/2307.03172) observed that the best
    performance typically arises when crucial data is positioned
    at the start or conclusion of the input context. Additionally,
    as the input context lengthens, performance drops notably, even
    in models designed for long contexts.".
    """

    @classmethod
    def class_name(cls) -> str:

View on GitHub (pinned to afd0fef371)

Solutions

  1. Use a valid mode for this postprocessor; check the class documentation for allowed values.
  2. Correct the mode argument.

When it happens

Trigger: Thrown at llama-index-core/llama_index/core/postprocessor/node.py:360 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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