fix(llm): preserve native continuation metadata (#28678)

This commit is contained in:
Kit Langton 2026-05-21 11:57:45 -04:00 committed by GitHub
commit 61390dbb49
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 843 additions and 194 deletions

View file

@ -219,6 +219,42 @@ describe("session.llm-native.request", () => {
])
})
test("maps stored provider metadata to native content metadata", () => {
const reasoning = Object.assign(
{ type: "reasoning" as const, text: "thinking" },
{
providerMetadata: {
openai: {
itemId: "rs_1",
reasoningEncryptedContent: "encrypted-state",
},
},
},
)
const request = LLMNative.request({
model: baseModel,
messages: [
{
role: "assistant",
content: [reasoning],
},
],
})
expect(request.messages).toMatchObject([
{
role: "assistant",
content: [
{
type: "reasoning",
text: "thinking",
providerMetadata: { openai: { itemId: "rs_1", reasoningEncryptedContent: "encrypted-state" } },
},
],
},
])
})
test("selects native request routes for provider packages", () => {
const openai = LLMNative.model({
model: { ...baseModel, api: { ...baseModel.api, url: "", npm: "@ai-sdk/openai" } },