fix(core): preserve assistant text metadata (#45650)

This commit is contained in:
Kit Langton
2026-08-27 23:01:33 -04:00
committed by GitHub
Unverified
parent e63779d9e1
commit 64ef85159d
3 changed files with 18 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@opencode-ai/core": patch
---
Preserve provider metadata on assistant text when replaying conversation history through AI SDK providers.
+1 -1
View File
@@ -514,7 +514,7 @@ function userPart(part: ContentPart): UserContent {
function assistantPart(part: ContentPart): AssistantContent {
switch (part.type) {
case "text":
return [{ type: "text", text: part.text }]
return [{ type: "text", text: part.text, providerOptions: metadataProviderOptions(part.providerMetadata) }]
case "media":
return [{ type: "file", mediaType: part.mediaType, data: part.data, filename: part.filename }]
case "reasoning":
+12
View File
@@ -326,6 +326,8 @@ it.effect("projects replay metadata onto AI SDK prompt parts", () =>
model: resolved,
messages: [
Message.assistant([
{ type: "text", text: "Answer", providerMetadata: { anthropic: { cacheControl: { type: "ephemeral" } } } },
{ type: "text", text: " without metadata" },
{ type: "reasoning", text: "Think", providerMetadata: { anthropic: { signature: "signed" } } },
{
type: "tool-call",
@@ -344,6 +346,16 @@ it.effect("projects replay metadata onto AI SDK prompt parts", () =>
{
role: "assistant",
content: [
{
type: "text",
text: "Answer",
providerOptions: { anthropic: { cacheControl: { type: "ephemeral" } } },
},
{
type: "text",
text: " without metadata",
providerOptions: undefined,
},
{
type: "reasoning",
text: "Think",