{"record":{"id":"2cb566afff45fab2","repo":"abhigyanpatwari/GitNexus","slug":"llm-returned-empty-streaming-response","errorCode":null,"errorMessage":"LLM returned empty streaming response","messagePattern":"LLM returned empty streaming response","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/wiki/llm-client.ts","lineNumber":521,"sourceCode":"        const delta = choice?.delta?.content;\n        if (delta) {\n          content += delta;\n          onChunk(content.length);\n        }\n      } catch {\n        // Skip malformed SSE chunks\n      }\n    }\n  }\n\n  if (contentFilterTriggered) {\n    throw new Error(\n      'content filter triggered mid-stream. The generated content was blocked by content policy. Adjust your prompt and retry.',\n    );\n  }\n\n  if (!content) {\n    throw new Error('LLM returned empty streaming response');\n  }\n\n  return { content };\n}\n","sourceCodeStart":503,"sourceCodeEnd":526,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/core/wiki/llm-client.ts#L503-L526","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Test the endpoint with a streaming curl (-N) and inspect whether data: chunks contain delta.content","If the server is non-compliant, fix it or use a compliant endpoint / different provider","Retry with `--verbose` to see the raw stream the CLI receives","Check the model is actually granted to the key (some providers stream an error frame instead of text)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await callLLM(prompt, config, undefined, { onChunk });\n} catch (err) {\n  if (err instanceof Error && err.message === 'LLM returned empty streaming response') {\n    return callLLM(prompt, config); // retry once — often transient\n  }\n  throw err;\n}","preventionTips":["Confirm the gateway emits standard SSE `data:` chunks containing delta.content (curl -N test)","Retry once on empty streams before escalating — many providers glitch transiently","Keep gateway/proxy firmware current; malformed SSE often comes from custom proxies"],"tags":["llm","streaming","sse","empty-response","gitnexus"],"backgroundTag":"empty-api-response","analyzedSha":"aac7515d2a8c50a1f8f923c6fb77218b333560d6","analyzedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}