abhigyanpatwari/GitNexus · error · Error

LLM returned empty streaming response

Error message

LLM returned empty streaming response

What it means

The SSE stream completed without any content delta: no chunk ever carried choice.delta.content (malformed chunks are silently skipped), so accumulated content is empty. The connection itself succeeded (response.ok), distinguishing this from API errors — the stream just yielded no usable text.

Source

Thrown at gitnexus/src/core/wiki/llm-client.ts:521

        const delta = choice?.delta?.content;
        if (delta) {
          content += delta;
          onChunk(content.length);
        }
      } catch {
        // Skip malformed SSE chunks
      }
    }
  }

  if (contentFilterTriggered) {
    throw new Error(
      'content filter triggered mid-stream. The generated content was blocked by content policy. Adjust your prompt and retry.',
    );
  }

  if (!content) {
    throw new Error('LLM returned empty streaming response');
  }

  return { content };
}

View on GitHub (pinned to aac7515d2a)

Solutions

  1. Test the endpoint with a streaming curl (-N) and inspect whether data: chunks contain delta.content
  2. If the server is non-compliant, fix it or use a compliant endpoint / different provider
  3. Retry with `--verbose` to see the raw stream the CLI receives
  4. Check the model is actually granted to the key (some providers stream an error frame instead of text)
Defensive patterns

Strategy: retry

Try / catch

try {
  await callLLM(prompt, config, undefined, { onChunk });
} catch (err) {
  if (err instanceof Error && err.message === 'LLM returned empty streaming response') {
    return callLLM(prompt, config); // retry once — often transient
  }
  throw err;
}

Prevention

When it happens

Trigger: Provider sends only keep-alive/role chunks or empty deltas; all data lines fail JSON.parse or lack the expected shape; model legitimately produced zero tokens (empty completion); proxy mangling the SSE framing so every chunk is skipped.

Common situations: Non-compliant SSE implementations in self-hosted gateways; finish_reason=length with zero output; authorization-limited models that connect but emit nothing; HTTP/1.1 buffers or middlewares splitting lines incorrectly.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@aac7515d2a (2026-08-20). Data as JSON: /api/errors/2cb566afff45fab2. Report an issue: GitHub.