Claude Sonnet 4.5 Throws "text content block must contain non-whitespace text" #2241

Closed
opened 2026-02-16 17:34:48 -05:00 by yindo · 4 comments
Owner

Originally created by @AbbasCiatek on GitHub (Oct 23, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

Using Claude Sonnet 4.5 and GLM.4.6 and switching between them based on the task, after switching from GLM 4.6 to Claude Sonnet 4.5 and sending a message it returns error "messages: text content block must contain non-whitespace text"

OpenCode version

15.4

Steps to reproduce

  1. Start a new session
  2. Use GLM 4.6 to edit some files do somethings
  3. Switch to Claude Sonnet 4.5
  4. Send message
  5. (you might need to switch multiple times between the models to get the error)
  6. Profit.

Screenshot and/or share link

Image

Operating System

Arch Linux (btw)

Terminal

Wizterm

Originally created by @AbbasCiatek on GitHub (Oct 23, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description Using Claude Sonnet 4.5 and GLM.4.6 and switching between them based on the task, after switching from GLM 4.6 to Claude Sonnet 4.5 and sending a message it returns error "messages: text content block must contain non-whitespace text" ### OpenCode version 15.4 ### Steps to reproduce 1. Start a new session 2. Use GLM 4.6 to edit some files do somethings 3. Switch to Claude Sonnet 4.5 4. Send message 5. (you might need to switch multiple times between the models to get the error) 6. Profit. ### Screenshot and/or share link <img width="1914" height="436" alt="Image" src="https://github.com/user-attachments/assets/c39d7542-9000-4ab3-846d-3d33867ff441" /> ### Operating System Arch Linux (btw) ### Terminal Wizterm
yindo added the bug label 2026-02-16 17:34:48 -05:00
yindo closed this issue 2026-02-16 17:34:48 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 23, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #1681: Same exact error "text content blocks must contain non-whitespace text" occurring when using /compact command
  • #3035: Model switching between reasoning and non-reasoning models causes context confusion and errors
  • #2655: Similar "non-empty content" validation error with Claude models

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Oct 23, 2025): This issue might be a duplicate of existing issues. Please check: - #1681: Same exact error "text content blocks must contain non-whitespace text" occurring when using /compact command - #3035: Model switching between reasoning and non-reasoning models causes context confusion and errors - #2655: Similar "non-empty content" validation error with Claude models Feel free to ignore if none of these address your specific case.
Author
Owner

@levniko commented on GitHub (Oct 23, 2025):

this is happening for me too

Opencode v0.15.14
Claude Opus 4.1
Claude Sonnet 4.5

@levniko commented on GitHub (Oct 23, 2025): this is happening for me too Opencode v0.15.14 Claude Opus 4.1 Claude Sonnet 4.5
Author
Owner

@rekram1-node commented on GitHub (Oct 23, 2025):

ill take a look, its kinda annoying because glm makes those whitespace chunks but sonnet wont accept them so we need to walk the line and handle both things

@rekram1-node commented on GitHub (Oct 23, 2025): ill take a look, its kinda annoying because glm makes those whitespace chunks but sonnet wont accept them so we need to walk the line and handle both things
Author
Owner

@rekram1-node commented on GitHub (Nov 11, 2025):

I think anthropic stopped enforcing this, I cannot replicate this error at all, if anyone can I will gladly reopen just pleaseee attach a session export opencode export > err.json << Select a session from the list that u replicated the error in

@rekram1-node commented on GitHub (Nov 11, 2025): I think anthropic stopped enforcing this, I cannot replicate this error at all, if anyone can I will gladly reopen just pleaseee attach a session export `opencode export > err.json` << Select a session from the list that u replicated the error in
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2241