{"record":{"id":"0512377d484ac050","repo":"earendil-works/pi","slug":"llama-cpp-sse-returned-http-response-status","errorCode":null,"errorMessage":"llama.cpp SSE returned HTTP ${response.status}","messagePattern":"llama\\.cpp SSE returned HTTP (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/extensions/llama/client.ts","lineNumber":217,"sourceCode":"\n\tasync unloadAndWait(model: string, signal?: AbortSignal): Promise<void> {\n\t\tawait this.unload(model, signal);\n\t\twhile (true) {\n\t\t\tconst entry = (await this.list({ signal })).find((candidate) => candidate.id === model);\n\t\t\tif (!entry || entry.status.value === \"unloaded\") return;\n\t\t\tawait sleep(100, signal);\n\t\t}\n\t}\n\n\tasync download(model: string, signal?: AbortSignal): Promise<void> {\n\t\tawait this.request(\"/models\", { method: \"POST\", body: JSON.stringify({ model }), signal });\n\t}\n\n\tasync watch(onEvent: (event: LlamaModelEvent) => void, signal?: AbortSignal): Promise<void> {\n\t\tconst headers = new Headers();\n\t\tif (this.apiKey) headers.set(\"Authorization\", `Bearer ${this.apiKey}`);\n\t\tconst response = await fetch(`${this.serverUrl}/models/sse`, { headers, signal });\n\t\tif (!response.ok || !response.body) throw new Error(`llama.cpp SSE returned HTTP ${response.status}`);\n\t\tconst reader = response.body.getReader();\n\t\tconst decoder = new TextDecoder();\n\t\tlet buffer = \"\";\n\t\twhile (true) {\n\t\t\tconst chunk = await reader.read();\n\t\t\tif (chunk.done) break;\n\t\t\tbuffer += decoder.decode(chunk.value, { stream: true }).replaceAll(\"\\r\\n\", \"\\n\");\n\t\t\tlet boundary = buffer.indexOf(\"\\n\\n\");\n\t\t\twhile (boundary >= 0) {\n\t\t\t\tconst frame = buffer.slice(0, boundary);\n\t\t\t\tbuffer = buffer.slice(boundary + 2);\n\t\t\t\tconst data = frame\n\t\t\t\t\t.split(\"\\n\")\n\t\t\t\t\t.filter((line) => line.startsWith(\"data:\"))\n\t\t\t\t\t.map((line) => line.slice(5).trimStart())\n\t\t\t\t\t.join(\"\\n\");\n\t\t\t\tif (data) {\n\t\t\t\t\ttry {","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/coding-agent/src/extensions/llama/client.ts#L199-L235","documentation":"Error \"llama.cpp SSE returned HTTP ${response.status}\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/coding-agent/src/extensions/llama/client.ts:217 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"}