fix: fix the itemId stripping logic, this time it should fix that id issue w/ gpt models fr

This commit is contained in:
Aiden Cline
2026-01-16 11:32:12 -06:00
parent 9a48f8e9e3
commit 40836e9683
2 changed files with 88 additions and 4 deletions

View File

@@ -805,6 +805,82 @@ describe("ProviderTransform.message - strip openai metadata when store=false", (
expect(result[0].content[0].providerOptions?.openai?.itemId).toBeUndefined()
})
test("strips metadata using providerID key when store is false", () => {
const opencodeModel = {
...openaiModel,
providerID: "opencode",
api: {
id: "opencode-test",
url: "https://api.opencode.ai",
npm: "@ai-sdk/openai-compatible",
},
}
const msgs = [
{
role: "assistant",
content: [
{
type: "text",
text: "Hello",
providerOptions: {
opencode: {
itemId: "msg_123",
otherOption: "value",
},
},
},
],
},
] as any[]
const result = ProviderTransform.message(msgs, opencodeModel, { store: false }) as any[]
expect(result[0].content[0].providerOptions?.opencode?.itemId).toBeUndefined()
expect(result[0].content[0].providerOptions?.opencode?.otherOption).toBe("value")
})
test("strips itemId across all providerOptions keys", () => {
const opencodeModel = {
...openaiModel,
providerID: "opencode",
api: {
id: "opencode-test",
url: "https://api.opencode.ai",
npm: "@ai-sdk/openai-compatible",
},
}
const msgs = [
{
role: "assistant",
providerOptions: {
openai: { itemId: "msg_root" },
opencode: { itemId: "msg_opencode" },
extra: { itemId: "msg_extra" },
},
content: [
{
type: "text",
text: "Hello",
providerOptions: {
openai: { itemId: "msg_openai_part" },
opencode: { itemId: "msg_opencode_part" },
extra: { itemId: "msg_extra_part" },
},
},
],
},
] as any[]
const result = ProviderTransform.message(msgs, opencodeModel, { store: false }) as any[]
expect(result[0].providerOptions?.openai?.itemId).toBeUndefined()
expect(result[0].providerOptions?.opencode?.itemId).toBeUndefined()
expect(result[0].providerOptions?.extra?.itemId).toBeUndefined()
expect(result[0].content[0].providerOptions?.openai?.itemId).toBeUndefined()
expect(result[0].content[0].providerOptions?.opencode?.itemId).toBeUndefined()
expect(result[0].content[0].providerOptions?.extra?.itemId).toBeUndefined()
})
test("does not strip metadata for non-openai packages when store is not false", () => {
const anthropicModel = {
...openaiModel,