run-llama/llama_index · error · ValueError

Cannot specify both query_str and query_bundle

Error message

Cannot specify both query_str and query_bundle

What it means

Error "Cannot specify both query_str and query_bundle" thrown in run-llama/llama_index.

Source

Thrown at llama-index-core/llama_index/core/postprocessor/rankGPT_rerank.py:99

        items = {
            "query": query_bundle.query_str,
            "hits": [{"content": node.get_content()} for node in nodes],
        }

        messages = self.create_permutation_instruction(item=items)
        permutation = await self.arun_llm(messages=messages)
        return self._llm_result_to_nodes(permutation, nodes, items)

    async def apostprocess_nodes(
        self,
        nodes: List[NodeWithScore],
        query_bundle: Optional[QueryBundle] = None,
        query_str: Optional[str] = None,
    ) -> List[NodeWithScore]:
        """Postprocess nodes asynchronously."""
        if query_str is not None and query_bundle is not None:
            raise ValueError("Cannot specify both query_str and query_bundle")
        elif query_str is not None:
            query_bundle = QueryBundle(query_str)
        else:
            pass
        return await self._apostprocess_nodes(nodes, query_bundle)

    def _llm_result_to_nodes(
        self, permutation: ChatResponse, nodes: List[NodeWithScore], items: Dict
    ) -> List[NodeWithScore]:
        if permutation.message is not None and permutation.message.content is not None:
            rerank_ranks = self._receive_permutation(
                items, str(permutation.message.content)
            )
            if self.verbose:
                print_text(f"After Reranking, new rank list for nodes: {rerank_ranks}")

            initial_results: List[NodeWithScore] = []

View on GitHub (pinned to afd0fef371)

Solutions

  1. Pass either query_str or query_bundle, not both.
  2. Remove one of the two arguments from the rerank call.

When it happens

Trigger: Thrown at llama-index-core/llama_index/core/postprocessor/rankGPT_rerank.py:99 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/79f2a7a8cccf68ca. Report an issue: GitHub.