AI_APICallError: messages.157: all messages must have non-empty content except for the optional final assistant message #1747

Closed
opened 2026-02-16 17:32:26 -05:00 by yindo · 12 comments
Owner

Originally created by @esafak on GitHub (Sep 17, 2025).

Originally assigned to: @rekram1-node on GitHub.

This is with anthropic claude opus 4.1, opencode 0.9.11, nushell on macos.

Originally created by @esafak on GitHub (Sep 17, 2025). Originally assigned to: @rekram1-node on GitHub. This is with anthropic claude opus 4.1, opencode 0.9.11, nushell on macos.
yindo closed this issue 2026-02-16 17:32:26 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Sep 17, 2025):

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

  • #2546: Similar API error about message content validation with trailing whitespace
  • #1681: Related error about text content blocks requiring non-whitespace text
  • #1295: Same exact error about final assistant content and trailing whitespace

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

@github-actions[bot] commented on GitHub (Sep 17, 2025): This issue might be a duplicate of existing issues. Please check: - #2546: Similar API error about message content validation with trailing whitespace - #1681: Related error about text content blocks requiring non-whitespace text - #1295: Same exact error about final assistant content and trailing whitespace Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Sep 17, 2025):

I just fixed this: https://github.com/sst/opencode/pull/2651

Assuming you had a message you aborted in the session?

U may be able to get around this by doing a /undo and then continuing

Either way: in next release this should be fixed!

@rekram1-node commented on GitHub (Sep 17, 2025): I just fixed this: https://github.com/sst/opencode/pull/2651 Assuming you had a message you aborted in the session? U may be able to get around this by doing a /undo and then continuing Either way: in next release this should be fixed!
Author
Owner

@esafak commented on GitHub (Sep 17, 2025):

Aborting often results in such errors, yes. Does undo delete the last entry?

@esafak commented on GitHub (Sep 17, 2025): Aborting often results in such errors, yes. Does undo delete the last entry?
Author
Owner

@rekram1-node commented on GitHub (Sep 17, 2025):

Yeah it will rewind to your last message so the most recent loop + last message you sent are all "deleted" (you can hit /redo too) and the prompt box will be populated with the last msg you sent

@rekram1-node commented on GitHub (Sep 17, 2025): Yeah it will rewind to your last message so the most recent loop + last message you sent are all "deleted" (you can hit /redo too) and the prompt box will be populated with the last msg you sent
Author
Owner

@rekram1-node commented on GitHub (Sep 17, 2025):

closing since commit to fix has been merged, will be in next release

@rekram1-node commented on GitHub (Sep 17, 2025): closing since commit to fix has been merged, will be in next release
Author
Owner

@arshbot commented on GitHub (Dec 27, 2025):

Running into this issue again, /undo doesn't seem to get past it. Occurred after linking anthropic mid chat. chat window froze and window had to be closed.

@arshbot commented on GitHub (Dec 27, 2025): Running into this issue again, /undo doesn't seem to get past it. Occurred after linking anthropic mid chat. chat window froze and window had to be closed.
Author
Owner

@andymac4182 commented on GitHub (Jan 4, 2026):

I am still getting this. It appears to have happened again.

@andymac4182 commented on GitHub (Jan 4, 2026): I am still getting this. It appears to have happened again.
Author
Owner

@rekram1-node commented on GitHub (Jan 4, 2026):

@andymac4182 can u share a session?

@rekram1-node commented on GitHub (Jan 4, 2026): @andymac4182 can u share a session?
Author
Owner

@arshbot commented on GitHub (Jan 4, 2026):

Can reproduce by starting a session with glm, and later switching to any anthropic model.

@arshbot commented on GitHub (Jan 4, 2026): Can reproduce by starting a session with glm, and later switching to any anthropic model.
Author
Owner

@rekram1-node commented on GitHub (Jan 4, 2026):

ahh

@rekram1-node commented on GitHub (Jan 4, 2026): ahh
Author
Owner

@madeleineostoja commented on GitHub (Feb 4, 2026):

Also still seeing this error, exclusively when interrupting an agent while thinking

@madeleineostoja commented on GitHub (Feb 4, 2026): Also still seeing this error, exclusively when interrupting an agent while thinking
Author
Owner

@kiennq commented on GitHub (Feb 7, 2026):

I got this issue with Copilot Claude model, we should expand the check for trimming to all anthropic models, regardless of ai-sdk.

@kiennq commented on GitHub (Feb 7, 2026): I got this issue with Copilot Claude model, we should expand the check for trimming to all anthropic models, regardless of ai-sdk.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1747