FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

ignore: split up reasoning transforms (#24574) · AIALRA-0/opencode-turn-engine@a9ddfde · GitHub

Repository navigation

Commit a9ddfde

Browse files
authored
ignore: split up reasoning transforms (anomalyco#24574)
1 parent c6e2bdb commit a9ddfde

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

‎packages/opencode/src/provider/transform.ts‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff 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") {

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL