[BUG]: Empty content error when switching from Cerebras GLM to Claude Opus #8443

Open
opened 2026-02-16 18:09:59 -05:00 by yindo · 2 comments
Owner

Originally created by @srs-adamr on GitHub (Feb 3, 2026).

Originally assigned to: @rekram1-node on GitHub.

Problem

When switching from Cerebras GLM 4.7 to Claude Opus 4.5 in the same session, I get this error:

messages.1: all messages must have non-empty content except for the optional final assistant message

This makes it impossible to switch between models during development sessions.

Steps to Reproduce

  1. Start a session with build agent (Cerebras GLM 4.7)
  2. Send a few messages
  3. Switch to plan agent (Claude Opus 4.5 with extended thinking)
  4. Try to send a message
  5. Error occurs

Environment

  • OpenCode version: 1.1.49
  • Provider: Cerebras (GLM 4.7) → Anthropic (Opus 4.5)
  • OS: macOS

Related Issues

  • #6418 - Invalid signature in thinking block (different error but related to model switching)
  • #2655 - Empty message content (closed, PR #2651 merged)
  • #9042 - Interrupted thinking-only message (closed)
  • #6446 - Empty message content during compaction (closed)

Notes

  • PR #11569 was merged before v1.1.49 release but doesn't seem to fix this specific case
  • PR #11882 is open but has failing tests
  • This is a critical blocker for workflows that require switching between GLM and Claude models
Originally created by @srs-adamr on GitHub (Feb 3, 2026). Originally assigned to: @rekram1-node on GitHub. ### Problem When switching from Cerebras GLM 4.7 to Claude Opus 4.5 in the same session, I get this error: ``` messages.1: all messages must have non-empty content except for the optional final assistant message ``` This makes it impossible to switch between models during development sessions. ### Steps to Reproduce 1. Start a session with `build` agent (Cerebras GLM 4.7) 2. Send a few messages 3. Switch to `plan` agent (Claude Opus 4.5 with extended thinking) 4. Try to send a message 5. Error occurs ### Environment - OpenCode version: 1.1.49 - Provider: Cerebras (GLM 4.7) → Anthropic (Opus 4.5) - OS: macOS ### Related Issues - #6418 - Invalid signature in thinking block (different error but related to model switching) - #2655 - Empty message content (closed, PR #2651 merged) - #9042 - Interrupted thinking-only message (closed) - #6446 - Empty message content during compaction (closed) ### Notes - PR #11569 was merged before v1.1.49 release but doesn't seem to fix this specific case - PR #11882 is open but has failing tests - This is a critical blocker for workflows that require switching between GLM and Claude models
Author
Owner

@github-actions[bot] commented on GitHub (Feb 3, 2026):

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

  • #11798: TypeError: undefined is not an object (evaluating 'agent.name') in createUserMessage - related to message creation during model/agent switching
  • #2655: Empty message content (closed, PR #2651 merged) - similar error signature

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

@github-actions[bot] commented on GitHub (Feb 3, 2026): This issue might be a duplicate of existing issues. Please check: - #11798: TypeError: undefined is not an object (evaluating 'agent.name') in createUserMessage - related to message creation during model/agent switching - #2655: Empty message content (closed, PR #2651 merged) - similar error signature Feel free to ignore if none of these address your specific case.
Author
Owner

@srs-adamr commented on GitHub (Feb 3, 2026):

Correction: This is NOT a duplicate of #6418.

After deeper analysis, this is a different error with a different root cause:

Issue Error Root Cause Fix
#6418 Invalid signature in thinking block GLM thinking blocks have incompatible signatures PR #11569 (merged)
This issue all messages must have non-empty content GLM reasoning parts stripped, leaving empty message PR #11882 (OPEN)

The Failure Path

  1. Use Cerebras GLM 4.7 (produces reasoning/thinking parts)
  2. Switch to Claude Opus (Anthropic provider)
  3. Empty content filter runs BEFORE GLM reasoning is processed
  4. GLM reasoning handler strips reasoning parts → message now has empty array
  5. Claude API rejects: "non-empty content"

Why PR #6383 (in v1.1.49) doesn't fix this

PR #6383 filters messages with only step-start parts. But GLM reasoning parts are NOT step-start parts - they pass the filter, then get stripped later, leaving empty content.

Required Fix

PR #11882 handles this by:

  1. Converting GLM thinking blocks to text (preserving content)
  2. Filtering empty content AFTER processing (not before)

PR #11882 is currently OPEN with failing tests and merge conflicts.

Environment

  • OpenCode: v1.1.49
  • Provider: Cerebras → Anthropic (NOT GitHub Copilot)
  • Models: cerebras/zai-glm-4.7anthropic/claude-opus-4-5
@srs-adamr commented on GitHub (Feb 3, 2026): **Correction: This is NOT a duplicate of #6418.** After deeper analysis, this is a **different error** with a **different root cause**: | Issue | Error | Root Cause | Fix | |-------|-------|------------|-----| | #6418 | `Invalid signature in thinking block` | GLM thinking blocks have incompatible signatures | PR #11569 (merged) | | **This issue** | `all messages must have non-empty content` | GLM reasoning parts stripped, leaving empty message | **PR #11882 (OPEN)** | ### The Failure Path 1. Use Cerebras GLM 4.7 (produces reasoning/thinking parts) 2. Switch to Claude Opus (Anthropic provider) 3. Empty content filter runs BEFORE GLM reasoning is processed 4. GLM reasoning handler strips reasoning parts → message now has empty array 5. Claude API rejects: "non-empty content" ### Why PR #6383 (in v1.1.49) doesn't fix this PR #6383 filters messages with only `step-start` parts. But GLM reasoning parts are NOT `step-start` parts - they pass the filter, then get stripped later, leaving empty content. ### Required Fix **PR #11882** handles this by: 1. Converting GLM thinking blocks to text (preserving content) 2. Filtering empty content AFTER processing (not before) PR #11882 is currently OPEN with failing tests and merge conflicts. ### Environment - OpenCode: v1.1.49 - Provider: Cerebras → Anthropic (NOT GitHub Copilot) - Models: `cerebras/zai-glm-4.7` → `anthropic/claude-opus-4-5`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8443