{"record":{"id":"074cca1e0ed3dddd","repo":"microsoft/graphrag","slug":"no-intermediate-answers-found-in-primer-response","errorCode":null,"errorMessage":"No intermediate answers found in primer response. Ensure that the primer response includes intermediate answers.","messagePattern":"No intermediate answers found in primer response\\. Ensure that the primer response includes intermediate answers\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"packages/graphrag/graphrag/query/structured_search/drift_search/search.py","lineNumber":137,"sourceCode":"            search_results (SearchResult): The results from the primer search.\n\n        Returns\n        -------\n        DriftAction: Action generated from the primer response.\n\n        Raises\n        ------\n        RuntimeError: If no intermediate answers or follow-up queries are found in the primer response.\n        \"\"\"\n        response = search_results.response\n        if isinstance(response, list) and isinstance(response[0], dict):\n            intermediate_answers = [\n                i[\"intermediate_answer\"] for i in response if \"intermediate_answer\" in i\n            ]\n\n            if not intermediate_answers:\n                error_msg = \"No intermediate answers found in primer response. Ensure that the primer response includes intermediate answers.\"\n                raise RuntimeError(error_msg)\n\n            intermediate_answer = \"\\n\\n\".join([\n                i[\"intermediate_answer\"] for i in response if \"intermediate_answer\" in i\n            ])\n\n            follow_ups = [fu for i in response for fu in i.get(\"follow_up_queries\", [])]\n\n            if not follow_ups:\n                error_msg = \"No follow-up queries found in primer response. Ensure that the primer response includes follow-up queries.\"\n                raise RuntimeError(error_msg)\n\n            score = sum(i.get(\"score\", float(\"-inf\")) for i in response) / len(response)\n            response_data = {\n                \"intermediate_answer\": intermediate_answer,\n                \"follow_up_queries\": follow_ups,\n                \"score\": score,\n            }\n            return DriftAction.from_primer_response(query, response_data)","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/microsoft/graphrag/blob/f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704/packages/graphrag/graphrag/query/structured_search/drift_search/search.py#L119-L155","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Retry the query; transient malformed LLM output is often intermittent","Use a stronger instruction-following model for the drift primer (e.g. a recent ChatGPT/GPT-4-class model)","If you customized the DRIFT primer prompt, ensure it still instructs the model to return intermediate_answer and follow_up_queries per report","Increase max_tokens enough that the multi-part primer JSON response is not truncated","Log the raw primer response to confirm the model is returning parseable JSON with the expected keys"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"def has_intermediate_answers(response) -> bool:\n    return bool(response) and all(isinstance(i, dict) for i in response) and any(\"intermediate_answer\" in i for i in response)","tryCatchPattern":"from graphrag.query.structured_search.drift_search.search import DriftSearch\n\nfor attempt in range(3):\n    try:\n        result = await drift_search.aresolve(query)\n        break\n    except RuntimeError as e:\n        if \"intermediate answers\" in str(e) and attempt < 2:\n            continue  # malformed primer response, retry\n        raise","preventionTips":["Use a strong instruction-following model for the DRIFT primer step","Avoid customizing the primer prompt in ways that drop the intermediate_answer field requirement","Set max_tokens high enough for the full multi-report JSON response"],"tags":["graphrag","drift-search","llm-response-parsing","runtime-error"],"backgroundTag":"llm-output-parsing-failed","analyzedSha":"f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704","analyzedAt":"2026-08-27T11:16:29.677Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}