abhigyanpatwari/GitNexus · error · Error
content filter triggered mid-stream. The generated content w
Error message
content filter triggered mid-stream. The generated content was blocked by content policy. Adjust your prompt and retry.
What it means
During SSE streaming, the client saw a content_filter flag in the stream before/at completion and discards the partial content, telling you the generated text was blocked by content policy mid-generation. This differs from the non-streaming Azure 400 case: the request was accepted and streaming started, then the provider's safety system cut it off.
Source
Thrown at gitnexus/src/core/wiki/llm-client.ts:515
// Detect content filter finish reason — skip delta from this chunk
if (choice?.finish_reason === 'content_filter') {
contentFilterTriggered = true;
continue;
}
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
- Adjust the prompt/source content: rename or exclude the module whose page keeps triggering the filter
- Loosen/adjust the provider's content-filter configuration (Azure: filter settings per deployment)
- Switch to a different provider or model with different filtering
- Retry — mid-stream filters are often borderline-score dependent
Defensive patterns
Strategy: try-catch
Try / catch
try {
await callLLM(prompt, config, undefined, { onChunk });
} catch (err) {
if (err instanceof Error && err.message.includes('content filter triggered mid-stream')) {
// partial content already streamed via onChunk — persist it as a stub and continue
return { content: partialContent + '\n\n[Generation blocked by content filter]' };
}
throw err;
} Prevention
- Capture partial streamed content via onChunk so a filter kill doesn't lose everything
- Adjust provider filter thresholds for repos with security-heavy vocabulary
- Design wiki generation to skip-and-continue on per-module moderation failures
When it happens
Trigger: Streaming call (useStream) where the provider emits a content-filter finish reason or error frame partway through; model begins a doc page whose generated content (often security/exploit-adjacent code text) trips filters after several tokens.
Common situations: Wiki generation for repos with security-tooling, weapon, drug, or graphic naming; providers with strict streaming filters (Azure OpenAI, some gateways); intermittent — same repo can pass or fail depending on sampled content.
Related errors
- Azure content filter blocked this request. The prompt trigge
- LLM returned empty streaming response
- Streaming PDG manifest collides with a structural node CSV f
- Streaming PDG manifest collides with a structural relationsh
- PdgEmitSink: ${errors.length} streamed CSV writer(s) hit an
AI-assisted analysis of abhigyanpatwari/GitNexus@aac7515d2a (2026-08-20).
Data as JSON: /api/errors/a7a1a5e9c59b00c2.
Report an issue: GitHub.