Skip to content

text content blocks must be non-empty when using Claude models and tools #24087

Closed as not planned

Description

@yexiaoxue2000-rgb

Description

Describe the bug
When using OpenCode with any Claude models, I frequently encounter an API error: text content blocks must be non-empty. This error typically occurs during tool usage (like reading files or searching). Once the error appears, the current conversation becomes unusable, and I have to start a completely new session to continue working.

To Reproduce
Steps to reproduce the behavior:

  1. Start a new session with OpenCode using a Claude model (Sonnet/Opus).
  2. Ask the agent to perform tasks that involve using tools (e.g., exploring project structure, reading multiple files, or searching).
  3. The agent attempts to call a tool or respond.
  4. The error text content blocks must be non-empty is thrown, and the agent stops responding properly.

Expected behavior
The agent should successfully execute tools and format the API request correctly without sending empty text content blocks to the Anthropic API.

Logs / Error Output

BadRequestError: 400 {"type":"error","error":{"type":"invalid_request_error","message":"text content blocks must be non-empty"}}
    at APIError.generate (node_modules/@anthropic-ai/sdk/error.js:...)
    at Anthropic.makeRequest (node_modules/@anthropic-ai/sdk/core.js:...)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

<img width="456" height="88" alt="Image" src="https://github.com/user-attachments/assets/e1a3a38d-00b6-4edf-940b-9f99f7f371aa" />

### Plugins

没有

### OpenCode version

最新版

### Steps to reproduce

_No response_

### Screenshot and/or share link

<img width="456" height="88" alt="Image" src="https://github.com/user-attachments/assets/544fdfb6-4bf1-4846-be7a-1150fe60410e" />

### Operating System

w11

### Terminal

_No response_

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 24, 2026
  2. github-actions commented on Apr 24, 2026

    @github-actions
    Contributor

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

    If your issue is the same, please add a thumbs-up or comment on the existing issue rather than opening a new one.

  3. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  4. github-actions commented on Jul 4, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions