microsoft/graphrag · error · RuntimeError

No intermediate answers found in primer response. Ensure tha

Error message

No intermediate answers found in primer response. Ensure that the primer response includes intermediate answers.

What it means

DRIFT search primes by sending the query plus community reports to the LLM and parsing the response into intermediate answers. If the parsed response contains no 'intermediate_answer' keys at all, this RuntimeError is raised, meaning the primer LLM output was empty, malformed, or the model did not follow the response format.

Source

Thrown at packages/graphrag/graphrag/query/structured_search/drift_search/search.py:137

            search_results (SearchResult): The results from the primer search.

        Returns
        -------
        DriftAction: Action generated from the primer response.

        Raises
        ------
        RuntimeError: If no intermediate answers or follow-up queries are found in the primer response.
        """
        response = search_results.response
        if isinstance(response, list) and isinstance(response[0], dict):
            intermediate_answers = [
                i["intermediate_answer"] for i in response if "intermediate_answer" in i
            ]

            if not intermediate_answers:
                error_msg = "No intermediate answers found in primer response. Ensure that the primer response includes intermediate answers."
                raise RuntimeError(error_msg)

            intermediate_answer = "\n\n".join([
                i["intermediate_answer"] for i in response if "intermediate_answer" in i
            ])

            follow_ups = [fu for i in response for fu in i.get("follow_up_queries", [])]

            if not follow_ups:
                error_msg = "No follow-up queries found in primer response. Ensure that the primer response includes follow-up queries."
                raise RuntimeError(error_msg)

            score = sum(i.get("score", float("-inf")) for i in response) / len(response)
            response_data = {
                "intermediate_answer": intermediate_answer,
                "follow_up_queries": follow_ups,
                "score": score,
            }
            return DriftAction.from_primer_response(query, response_data)

View on GitHub (pinned to f40e9a26ce)

Solutions

  1. Retry the query; transient malformed LLM output is often intermittent
  2. Use a stronger instruction-following model for the drift primer (e.g. a recent ChatGPT/GPT-4-class model)
  3. If you customized the DRIFT primer prompt, ensure it still instructs the model to return intermediate_answer and follow_up_queries per report
  4. Increase max_tokens enough that the multi-part primer JSON response is not truncated
  5. Log the raw primer response to confirm the model is returning parseable JSON with the expected keys
Defensive patterns

Strategy: retry

Type guard

def has_intermediate_answers(response) -> bool:
    return bool(response) and all(isinstance(i, dict) for i in response) and any("intermediate_answer" in i for i in response)

Try / catch

from graphrag.query.structured_search.drift_search.search import DriftSearch

for attempt in range(3):
    try:
        result = await drift_search.aresolve(query)
        break
    except RuntimeError as e:
        if "intermediate answers" in str(e) and attempt < 2:
            continue  # malformed primer response, retry
        raise

Prevention

When it happens

Trigger: Calling DriftSearch.search where the primer call to the LLM returns an empty list, JSON that omits intermediate_answer keys, or a response that failed to parse into the expected list-of-dicts schema (e.g. wrong/weak model, truncated output, or an incompatible prompt template).

Common situations: Using a small local model that ignores the structured output instructions, exceeding output token limits so the JSON is cut off, customizing the drift primer prompt and breaking the expected keys, or API errors surfacing as empty parsed responses.

Related errors


AI-assisted analysis of microsoft/graphrag@f40e9a26ce (2026-08-27). Data as JSON: /api/errors/074cca1e0ed3dddd. Report an issue: GitHub.