{"record":{"id":"63671822475aec80","repo":"earendil-works/pi","slug":"turn-prefix-summarization-failed-response-error","errorCode":null,"errorMessage":"Turn prefix summarization failed: ${response.errorMessage || \"Unknown error\"}","messagePattern":"Turn prefix summarization failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/core/compaction/compaction.ts","lineNumber":987,"sourceCode":"\tconst maxTokens = Math.min(\n\t\tMath.floor(0.5 * reserveTokens),\n\t\tmodel.maxTokens > 0 ? model.maxTokens : Number.POSITIVE_INFINITY,\n\t); // Smaller budget for turn prefix\n\tconst llmMessages = convertToLlm(messages);\n\tconst conversationText = serializeConversation(llmMessages);\n\tconst promptText = `<conversation>\\n${conversationText}\\n</conversation>\\n\\n${TURN_PREFIX_SUMMARIZATION_PROMPT}`;\n\n\tconst response = await completeSummarization(\n\t\tmodel,\n\t\tbuildSummarizationContext(promptText),\n\t\tcreateSummarizationOptions(model, maxTokens, apiKey, headers, env, signal, thinkingLevel, sessionId),\n\t\tstreamFn,\n\t\tretry,\n\t\tcallbacks,\n\t);\n\n\tif (response.stopReason === \"error\") {\n\t\tthrow new Error(`Turn prefix summarization failed: ${response.errorMessage || \"Unknown error\"}`);\n\t}\n\tif (response.content.some((block) => block.type === \"toolCall\")) {\n\t\tthrow new Error(\"Turn prefix summarization attempted to call a tool\");\n\t}\n\n\treturn {\n\t\ttext: contentText(response.content),\n\t\tusage: response.usage,\n\t};\n}\n","sourceCodeStart":969,"sourceCodeEnd":998,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/coding-agent/src/core/compaction/compaction.ts#L969-L998","documentation":"Error \"Turn prefix summarization failed: ${response.errorMessage || \"Unknown error\"}\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/coding-agent/src/core/compaction/compaction.ts:987 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}