fix(provider): drop empty content messages after interleaved reasoning filter#17712
fix(provider): drop empty content messages after interleaved reasoning filter#17712jpvelasco wants to merge 1 commit intoanomalyco:devfrom
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Based on my searches, I found one potentially related PR: Related PR:
The other PRs found (like #16750 and #14637) deal with related normalizeMessages and interleaved reasoning concerns, but they appear to address different specific issues rather than duplicates. Note: PR #17712 is the current PR you're checking, so it's not listed as a duplicate of itself. |
13284f0 to
0816abf
Compare
…g filter The interleaved reasoning filter strips reasoning parts from assistant messages and moves them to providerOptions. When an assistant message contains only reasoning parts, this leaves content: [], which Bedrock's ConverseAPI rejects with a validation error. The session is permanently broken after this. Fixes anomalyco#17705
0816abf to
ecbe9e9
Compare
|
We independently hit this bug in a fork while using an openai-compatible provider routing to Anthropic models. Reasoning-only assistant messages became We arrived at the same fix — Clean, minimal fix. Would be great to see this merged. |
Issue for this PR
Fixes #17705
Type of change
What does this PR do?
The interleaved reasoning filter in
normalizeMessages()strips reasoning parts from assistant messages and moves them toproviderOptions. When an assistant message contains only reasoning parts (no text, no tool-call), this leavescontent: [], which Bedrock's ConverseAPI rejects with a validation error. The session is permanently broken after this.The empty content guard at lines 54-72 cannot catch this because it runs before the interleaved filter.
The fix adds a check after filtering reasoning parts: if
filteredContentis empty, the message is dropped. This follows the same pattern used by the existing empty content guard at line 68.How did you verify your code works?
bun turbo typecheck --filter=opencode)amazon-bedrock/zai.glm-4.7(the only Bedrock model currently withinterleaved: { field: "reasoning_content" }). Before the fix: crashes at step 14 with validation error. After the fix: completed 199 steps with 0 errors.Checklist