Skip to content

"AI_APICallError: Text content blocks must contain non-whitespace text" on /compact #1681

Closed

Description

@IshanArya

I am running the Claude Pro Max model with Opencode. Whenever I try to run /compact , I get the error:

AI_APICallError: system: text content blocks must contain non-whitespace text

And this ruins the formatting of the opencode terminal so I have to restart the command prompt. Eventually this makes opencode unusable because the auto-compact doesn't seem to work either.

I think the error originates from node_modules/@ai-sdk/provider/dist/index.js:62:5 .
At least, that is the minimal error I can see in the messed up opencode terminal.

Any thoughts?

Image

Activity

  1. self-assigned this
    on Aug 7, 2025
  2. changed the title [-]Text content blocks must contain non-whitespace text[/-] [+]"AI_APICallError: Text content blocks must contain non-whitespace text" on /compact[/+] on Aug 9, 2025
  3. IshanArya commented on Aug 14, 2025

    @IshanArya
    Author

    Hi, @thdxr any idea why this might be happening so I can look into it? I really like Opencode but this bug makes it really hard to use.

    I tried reinstalling Opencode and the issue persisted.

  4. rekram1-node commented on Aug 29, 2025

    @rekram1-node
    Contributor

    What model was this?

  5. DxTa commented on Oct 5, 2025

    @DxTa

    I got similar issue with Opus 4.1 via claude code subscription

  6. rekram1-node commented on Oct 5, 2025

    @rekram1-node
    Contributor

    can u share session?

  7. RaphGod commented on Oct 12, 2025

    @RaphGod

    Hello, I've got que same problem. Build with GLM 4.6 = > 0K
    when Plan Mode with Ko => AI_APICallError: messages: text content blocks must contain non-whitespace text
    undo or quit and launch opencode => AI_APICallError: messages: text content blocks must contain non-whitespace text
    Swap to Build mode => OK !
    Swap to plan mode => KO ! AI_APICallError: messages: text content blocks must contain non-whitespace text
    Swap to GLM in plan mode (instead of Claude Sonnet) ===> OK ! => make a plan => Build with GLM => Plan mode => talk with glm ok => swapto claude AI_APICallError: messages: text content blocks must contain non-whitespace text

    It seems like the model Claude is fall ! But if you start a new session with Claude it is OK !
    You go back to the falled session => KO : AI_APICallError: messages: text content blocks must contain non-whitespace text

    The problem is in the session wich is corrupted.

  8. RaphGod commented on Oct 12, 2025

    @RaphGod

    i can share session but not in public, tell me how I can send you

  9. rekram1-node commented on Oct 12, 2025

    @rekram1-node
    Contributor

    @RaphGod you can dm on discord or x if that works

  10. RaphGod commented on Oct 12, 2025

    @RaphGod

    I sent you in X ! the first It blocked me , but the second I can :-) You can open private vunlerability in github to send private issue. Hope this will help.

  11. IshanArya commented on Oct 15, 2025

    @IshanArya
    Author

    Hi I was using sonnet 4.1 before. However, with sonnet 4.5, when I call /compact, the terminal gets stuck on:

    Generating...
    Build claude-sonnet-4-5-20250929 (11:09 AM)
    
  12. rekram1-node commented on Oct 16, 2025

    @rekram1-node
    Contributor

    fix: d8a15e7

  13. reise69 commented on Oct 24, 2025

    @reise69

    Hello,

    I have configured the Haiku 4.5 model in default build. I am making my plan with a mixture of GLM 4.6 and Sonnet 4.5.

    As soon as I switch back to build and launch the go for modifications, I get the error ‘messages: text content blocks must contain non-whitespace text’.

    I only have this problem with Haiku 4.5.

    Does anyone else have this problem? Thank you for your help.

  14. rekram1-node commented on Oct 24, 2025

    @rekram1-node
    Contributor

    @reise69 i know what caused your issue ill fix soon

  15. IshanArya commented on Oct 28, 2025

    @IshanArya
    Author

    Awesome, /compact is working now, thank you!

  16. 777akot commented on Jan 29, 2026

    @777akot

    /undo until your message with whitespaces

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