Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions core/schemas/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1223,11 +1223,26 @@ func DeepCopyResponsesMessage(original ResponsesMessage) ResponsesMessage {
copy.Status = &copyStatus
}

if original.Phase != nil {
copy.Phase = new(string)
*copy.Phase = *original.Phase
}

if original.Role != nil {
copyRole := *original.Role
copy.Role = &copyRole
}

// Deep copy Author and Recipient (multi-agent collab_tool_call items).
// json.RawMessage is a []byte slice; copy the bytes so callers don't share
// (and mutate) the underlying array.
if original.Author != nil {
copy.Author = append(json.RawMessage(nil), original.Author...)
}
if original.Recipient != nil {
copy.Recipient = append(json.RawMessage(nil), original.Recipient...)
}

if original.Content != nil {
copy.Content = &ResponsesMessageContent{}

Expand Down Expand Up @@ -1377,6 +1392,17 @@ func deepCopyResponsesMessageContentBlock(original ResponsesMessageContentBlock)
copy.Text = &copyText
}

// Reasoning replay fields: Signature and EncryptedContent are echoed back
// verbatim to the provider, so they must survive the deep copy.
if original.Signature != nil {
copy.Signature = new(string)
*copy.Signature = *original.Signature
}
if original.EncryptedContent != nil {
copy.EncryptedContent = new(string)
*copy.EncryptedContent = *original.EncryptedContent
}

// Deep copy ResponsesInputMessageContentBlockImage
if original.ResponsesInputMessageContentBlockImage != nil {
copyImage := &ResponsesInputMessageContentBlockImage{}
Expand Down
22 changes: 22 additions & 0 deletions framework/streaming/responses.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package streaming

import (
"encoding/json"
"fmt"
"sort"
"strings"
Expand Down Expand Up @@ -219,6 +220,16 @@ func deepCopyResponsesMessage(original schemas.ResponsesMessage) schemas.Respons
}
}

// Deep copy Author and Recipient (multi-agent collab_tool_call items).
// json.RawMessage is a []byte slice; copy the bytes so accumulators don't
// share (and mutate) the underlying array.
if original.Author != nil {
copy.Author = append(json.RawMessage(nil), original.Author...)
}
if original.Recipient != nil {
copy.Recipient = append(json.RawMessage(nil), original.Recipient...)
}

// Deep copy ResponsesReasoning if present
if original.ResponsesReasoning != nil {
copy.ResponsesReasoning = &schemas.ResponsesReasoning{}
Expand Down Expand Up @@ -443,6 +454,17 @@ func deepCopyResponsesMessageContentBlock(original schemas.ResponsesMessageConte
copy.Text = &copyText
}

// Reasoning replay fields: Signature and EncryptedContent are echoed back
// verbatim to the provider, so they must survive the deep copy.
if original.Signature != nil {
copy.Signature = new(string)
*copy.Signature = *original.Signature
}
if original.EncryptedContent != nil {
copy.EncryptedContent = new(string)
*copy.EncryptedContent = *original.EncryptedContent
}

// Copy other specific content type fields as needed
if original.ResponsesOutputMessageContentText != nil {
t := *original.ResponsesOutputMessageContentText
Expand Down