mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-14 12:10:45 +03:00
fix(core): preserve assistant text metadata (#45650)
This commit is contained in:
committed by
GitHub
Unverified
parent
e63779d9e1
commit
64ef85159d
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@opencode-ai/core": patch
|
||||
---
|
||||
|
||||
Preserve provider metadata on assistant text when replaying conversation history through AI SDK providers.
|
||||
@@ -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":
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user