Description
github-copilot Claude models hit a hard 400 from the Anthropic /v1/messages endpoint once the conversation history contains an assistant turn whose only text block is whitespace.
Error:
AI_APICallError: messages: text content blocks must contain non-whitespace text
POST https://api.githubcopilot.com/v1/messages
The offending entry in the request body is a single space:
{"role":"assistant","content":[{"type":"text","text":" "}]}
Root cause: ProviderTransform.message (packages/opencode/src/provider/transform.ts) already strips empty text parts before sending to Anthropic, but the @ai-sdk/anthropic branch filters text with part.text !== "" (exact empty), so a whitespace-only " " slips through. The reasoning filter right beside it already uses .trim() — so the two are inconsistent. A lone-space text block reaches Anthropic and is rejected.
Affected Claude models (e.g. claude-opus-4.7, claude-opus-4.7-1m-internal) are listed and selectable — they just 400 on the next request once a whitespace-only assistant turn is in history. This is easy to hit when a model-fallback setup replays an empty/whitespace response to Claude.
I have a fix + tests ready and will open a PR referencing this issue.
Plugins
model-fallback plugin in use, but the bug is in core ProviderTransform and is plugin-independent
OpenCode version
1.16.2
Steps to reproduce
- Use a github-copilot Claude model (e.g. claude-opus-4.7).
- Get an assistant turn into history whose only text content is whitespace (e.g. an empty/whitespace response that is replayed to Claude — common with a model-fallback chain).
- Send another message. The request to /v1/messages fails with 400 "text content blocks must contain non-whitespace text".
Screenshot and/or share link
No response
Operating System
Windows 11
Terminal
Windows Terminal
Description
github-copilot Claude models hit a hard 400 from the Anthropic
/v1/messagesendpoint once the conversation history contains an assistant turn whose only text block is whitespace.Error:
The offending entry in the request body is a single space:
{"role":"assistant","content":[{"type":"text","text":" "}]}Root cause:
ProviderTransform.message(packages/opencode/src/provider/transform.ts) already strips empty text parts before sending to Anthropic, but the@ai-sdk/anthropicbranch filters text withpart.text !== ""(exact empty), so a whitespace-only" "slips through. Thereasoningfilter right beside it already uses.trim()— so the two are inconsistent. A lone-space text block reaches Anthropic and is rejected.Affected Claude models (e.g. claude-opus-4.7, claude-opus-4.7-1m-internal) are listed and selectable — they just 400 on the next request once a whitespace-only assistant turn is in history. This is easy to hit when a model-fallback setup replays an empty/whitespace response to Claude.
I have a fix + tests ready and will open a PR referencing this issue.
Plugins
model-fallback plugin in use, but the bug is in core ProviderTransform and is plugin-independent
OpenCode version
1.16.2
Steps to reproduce
Screenshot and/or share link
No response
Operating System
Windows 11
Terminal
Windows Terminal