earendil-works/pi · error

llama.cpp SSE returned HTTP

Error message

llama.cpp SSE returned HTTP ${response.status}

What it means

HTTP error surface for the SSE event-stream connection in LlamaClient.watch: the server rejected the streaming request with a non-2xx status, so model load/download progress events cannot be received.

Solutions

  1. Verify the llama.cpp router server is up and the URL is correct
  2. Check server logs for why the events endpoint returned an error
  3. Retry once the server is healthy
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at packages/coding-agent/src/extensions/llama/client.ts:217 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24). Data as JSON: /api/errors/0512377d484ac050. Report an issue: GitHub.

Appendix: source

Thrown at packages/coding-agent/src/extensions/llama/client.ts:217

	async unloadAndWait(model: string, signal?: AbortSignal): Promise<void> {
		await this.unload(model, signal);
		while (true) {
			const entry = (await this.list({ signal })).find((candidate) => candidate.id === model);
			if (!entry || entry.status.value === "unloaded") return;
			await sleep(100, signal);
		}
	}

	async download(model: string, signal?: AbortSignal): Promise<void> {
		await this.request("/models", { method: "POST", body: JSON.stringify({ model }), signal });
	}

	async watch(onEvent: (event: LlamaModelEvent) => void, signal?: AbortSignal): Promise<void> {
		const headers = new Headers();
		if (this.apiKey) headers.set("Authorization", `Bearer ${this.apiKey}`);
		const response = await fetch(`${this.serverUrl}/models/sse`, { headers, signal });
		if (!response.ok || !response.body) throw new Error(`llama.cpp SSE returned HTTP ${response.status}`);
		const reader = response.body.getReader();
		const decoder = new TextDecoder();
		let buffer = "";
		while (true) {
			const chunk = await reader.read();
			if (chunk.done) break;
			buffer += decoder.decode(chunk.value, { stream: true }).replaceAll("\r\n", "\n");
			let boundary = buffer.indexOf("\n\n");
			while (boundary >= 0) {
				const frame = buffer.slice(0, boundary);
				buffer = buffer.slice(boundary + 2);
				const data = frame
					.split("\n")
					.filter((line) => line.startsWith("data:"))
					.map((line) => line.slice(5).trimStart())
					.join("\n");
				if (data) {
					try {

View on GitHub (pinned to 4af9d21d3b)