This commit is contained in:
Aiden Cline
2026-04-15 14:45:36 -05:00
parent 3dea9e91d1
commit f4577c78bf
2 changed files with 50 additions and 1 deletions
@@ -1337,6 +1337,44 @@ describe("ProviderTransform.message - anthropic empty content filtering", () =>
{ type: "tool-call", toolCallId: "toolu_2", toolName: "glob", input: { pattern: "**/*.pdf" } },
])
})
test("splits vertex anthropic assistant messages when text trails tool calls", () => {
const model = {
...anthropicModel,
providerID: "google-vertex-anthropic",
api: {
id: "claude-sonnet-4@20250514",
url: "https://us-central1-aiplatform.googleapis.com",
npm: "@ai-sdk/google-vertex/anthropic",
},
}
const msgs = [
{
role: "assistant",
content: [
{ type: "tool-call", toolCallId: "toolu_1", toolName: "read", input: { filePath: "/root" } },
{ type: "tool-call", toolCallId: "toolu_2", toolName: "glob", input: { pattern: "**/*.pdf" } },
{ type: "text", text: "I checked your home directory and looked for PDF files." },
],
},
] as any[]
const result = ProviderTransform.message(msgs, model, {}) as any[]
expect(result).toHaveLength(2)
expect(result[0]).toMatchObject({
role: "assistant",
content: [{ type: "text", text: "I checked your home directory and looked for PDF files." }],
})
expect(result[1]).toMatchObject({
role: "assistant",
content: [
{ type: "tool-call", toolCallId: "toolu_1", toolName: "read", input: { filePath: "/root" } },
{ type: "tool-call", toolCallId: "toolu_2", toolName: "glob", input: { pattern: "**/*.pdf" } },
],
})
})
})
describe("ProviderTransform.message - strip openai metadata when store=false", () => {