This repository was archived by the owner on May 23, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
packages/opencode/src/provider Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,7 +52,28 @@ function normalizeMessages(
5252) : ModelMessage [ ] {
5353 // Anthropic rejects messages with empty content - filter out empty string messages
5454 // and remove empty text/reasoning parts from array content
55- if ( model . api . npm === "@ai-sdk/anthropic" || model . api . npm === "@ai-sdk/amazon-bedrock" ) {
55+ if ( model . api . npm === "@ai-sdk/anthropic" ) {
56+ msgs = msgs
57+ . map ( ( msg ) => {
58+ if ( typeof msg . content === "string" ) {
59+ if ( msg . content === "" ) return undefined
60+ return msg
61+ }
62+ if ( ! Array . isArray ( msg . content ) ) return msg
63+ const filtered = msg . content . filter ( ( part ) => {
64+ if ( part . type === "text" || part . type === "reasoning" ) {
65+ return part . text !== ""
66+ }
67+ return true
68+ } )
69+ if ( filtered . length === 0 ) return undefined
70+ return { ...msg , content : filtered }
71+ } )
72+ . filter ( ( msg ) : msg is ModelMessage => msg !== undefined && msg . content !== "" )
73+ }
74+
75+ // Bedrock specific transforms
76+ if ( model . api . npm === "@ai-sdk/amazon-bedrock" ) {
5677 msgs = msgs
5778 . map ( ( msg ) => {
5879 if ( typeof msg . content === "string" ) {
You can’t perform that action at this time.
0 commit comments