mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 20:11:08 +00:00
Issue #1101 follow-up. When a third-party Anthropic-compat backend streams thinking deltas without first emitting a `reasoning-start` content-block signal (DeepSeek's \`-v4-flash\` is the canonical offender), the Vercel AI SDK has nothing registered for the incoming \`part.id\` and enqueues an \`error\` chunk on \`fullStream\` with the text \`reasoning part <id> not found\` — once per orphan delta. The analogous error exists for text parts. These are internal SDK bookkeeping noise, not user-facing errors. Our \`case 'error'\` handler was treating each one as a real error: it appended an empty assistant message carrying the SDK string. The visible damage was a wall of red banners in the chat panel — but the worse damage was protocol-level. On the next turn we rebuild \`sdkMessages\` from local history; the placeholder assistants slot in between the assistant that holds the parallel \`tool_use\` blocks and the subsequent \`role: 'tool'\` messages with their results. The Anthropic SDK's \`groupIntoBlocks\` only merges *consecutive* tool messages into a single user block, so the tool_results no longer immediately follow their tool_use parent — and the backend rejects the request as \`400 messages.N: tool_use ids were found without tool_result blocks immediately after\`. \`messages.N\` was literally counting our 12-ish phantom assistants. Adds \`isSdkStreamStateError(error)\` to \`infrastructure/ai/shared/streamStateErrors.ts\` (matches \`/^(reasoning|text)\\s+part\\s+\\S+\\s+not\\s+found$/i\` against string / Error / \`{ message }\` shapes), and skips placeholder emission for matching errors in the streaming hook. Drops a \`console.warn\` so the noise is still visible in devtools when debugging. 5 unit tests cover positive matches, the Error/object wrappings, non-matches that should stay surfaced, and non-string inputs. Refs #1101. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>