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
1 change: 1 addition & 0 deletions core/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- fix: preserve encrypted reasoning as a Bedrock replay signature when translating Responses history [@zachgersh](https://github.com/zachgersh)
- feat: add proxy support for WebSocket-based realtime calls, mirroring existing HTTP proxy configuration (#5788)
- feat: add `WithFasthttpBufferSizes` option to `HTTPClientFactory` for configurable SCIM read/write buffers, fixing failures when IdP token endpoints return headers larger than the 4KB default (#5808)
- fix: move SSE heartbeat handling into a common structure so client-disconnect detection is proactive instead of only firing on the next write attempt (#5850)
Expand Down
31 changes: 31 additions & 0 deletions core/providers/bedrock/reasoning_replay_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package bedrock

import (
"testing"

"github.com/maximhq/bifrost/core/schemas"
"github.com/stretchr/testify/require"
)

// TestConvertBifrostReasoningToBedrockReasoningEncryptedContent verifies that
// encrypted reasoning replay data survives cross-provider translation into the
// Bedrock reasoning signature field. Responses reasoning items use an empty,
// non-nil Summary alongside EncryptedContent, so the converter must not treat
// the empty slice as visible reasoning and silently drop the replay payload.
func TestConvertBifrostReasoningToBedrockReasoningEncryptedContent(t *testing.T) {
encryptedContent := "EqQBCgIYAhIM...fixture"
message := &schemas.ResponsesMessage{
Type: schemas.Ptr(schemas.ResponsesMessageTypeReasoning),
ResponsesReasoning: &schemas.ResponsesReasoning{
Summary: []schemas.ResponsesReasoningSummary{},
EncryptedContent: &encryptedContent,
},
}

blocks := convertBifrostReasoningToBedrockReasoning(message)
require.Len(t, blocks, 1)
require.NotNil(t, blocks[0].ReasoningContent)
require.NotNil(t, blocks[0].ReasoningContent.ReasoningText)
require.Nil(t, blocks[0].ReasoningContent.ReasoningText.Text)
require.Equal(t, encryptedContent, *blocks[0].ReasoningContent.ReasoningText.Signature)
}
9 changes: 3 additions & 6 deletions core/providers/bedrock/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -4550,7 +4550,7 @@ func convertBifrostReasoningToBedrockReasoning(msg *schemas.ResponsesMessage) []
}
}
} else if msg.ResponsesReasoning != nil {
if msg.ResponsesReasoning.Summary != nil {
if len(msg.ResponsesReasoning.Summary) > 0 {
for _, reasoningContent := range msg.ResponsesReasoning.Summary {
reasoningBlock := BedrockContentBlock{
ReasoningContent: &BedrockReasoningContent{
Expand All @@ -4561,14 +4561,11 @@ func convertBifrostReasoningToBedrockReasoning(msg *schemas.ResponsesMessage) []
}
reasoningBlocks = append(reasoningBlocks, reasoningBlock)
}
} else if msg.ResponsesReasoning.EncryptedContent != nil {
// Bedrock doesn't have a direct equivalent to encrypted content,
// so we'll store it as a regular reasoning block with a special marker
encryptedText := fmt.Sprintf("[ENCRYPTED_REASONING: %s]", *msg.ResponsesReasoning.EncryptedContent)
} else if msg.ResponsesReasoning.EncryptedContent != nil && *msg.ResponsesReasoning.EncryptedContent != "" {
reasoningBlock := BedrockContentBlock{
ReasoningContent: &BedrockReasoningContent{
ReasoningText: &BedrockReasoningContentText{
Text: &encryptedText,
Signature: msg.ResponsesReasoning.EncryptedContent,
},
},
}
Expand Down