[bot] Bedrock Converse `reasoningContent` blocks not normalized — extended thinking traces break UI schema
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 82/100
Hướng nghiên cứu
Bắt đầu trong braintrust-sdk/src/main/java/dev/braintrust/instrumentation/InstrumentationSemConv.java, đọc tagBedrockRequest, tagBedrockResponse và normalizeBedrockMessage quanh các dòng 339–501. Sau đó kiểm tra BraintrustAWSBedrockTest.java và bổ sung coverage cho một reasoningContent block của Bedrock. Hoàn tất khi reasoningContent được chuẩn hóa với kiểu mong đợi, vẫn giữ nguyên nội dung của nó, và việc xử lý block hiện có vẫn nguyên vẹn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
<!-- provider-gap-audit: bedrock-reasoningcontent-not-normalized -->
Summary
InstrumentationSemConv.normalizeBedrockMessage() — the function that normalizes Bedrock Converse content blocks so they carry an explicit "type" field the Braintrust UI schema requires — recognizes text, toolUse, toolResult, and image blocks, but does not recognize reasoningContent, the official Bedrock Converse block type for extended thinking / Chain-of-Thought output (Claude 3.7+ and Amazon Nova reasoning models via additionalModelRequestFields.reasoning_config).
This is the same code path issue #85 describes as working correctly for tool use ("Non-streaming Converse calls handle tool use correctly — normalizeBedrockMessage() ... already recognizes toolUse, toolResult, and image"), but that issue is scoped to the streaming (ConverseStream) tool-use path and does not mention reasoningContent at all — this is a distinct gap in the shared, non-streaming-safe normalization helper used by both request and response tagging.
What is missing
In braintrust-sdk/src/main/java/dev/braintrust/instrumentation/InstrumentationSemConv.java, normalizeBedrockMessage() (lines 467–501):
if (block.has("text")) {
normalized.put("type", "text");
changed = true;
} else if (block.has("toolUse")) {
normalized.put("type", "tool_use");
changed = true;
} else if (block.has("toolResult")) {
normalized.put("type", "tool_result");
changed = true;
} else if (block.has("image")) {
normalized.put("type", "image");
changed = true;
}
There is no else if (block.has("reasoningContent")) branch. When a Bedrock Converse (or ConverseStream, once #85 is fixed) response contains a reasoningContent block ({"reasoningContent": {"reasoningText": {"text": "...", "signature": "..."}}}), it is left without a type field — unlike every sibling content-block type in the same array — so it doesn't match the schema the UI validates against for thread rendering (per this same method's own doc comment: "both the OpenAI and Anthropic schemas the UI validates against require an explicit type field").
This function is shared by both:
tagBedrockRequest()(line 389:inputArray.add(normalizeBedrockMessage(msg))) — affects multi-turn conversations that echo back a prior assistantreasoningContentblock (required by some models to preserve the reasoning trace across turns)tagBedrockResponse()(line 408:outputArray.add(normalizeBedrockMessage(message))) — affects the model's own reasoning output on the current turn
Braintrust docs status
unclear — the Braintrust docs list Bedrock as a supported provider (https://www.braintrust.dev/docs/integrations/ai-providers) but do not specifically document extended-thinking/reasoning content handling for Bedrock Converse.
Upstream sources
- AWS Bedrock Converse API —
reasoningContentblock, part of theContentBlockunion: https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ContentBlock.html - Amazon Nova extended reasoning guide (documents
reasoningContent/reasoningTextresponse shape): https://docs.aws.amazon.com/nova/latest/userguide/extended-thinking.html - Using Claude 3.7 Sonnet extended thinking via the Bedrock Converse API (
additionalModelRequestFields.reasoning_config, responsereasoningContent): https://seobs.medium.com/using-sonnet-3-7-reasoning-with-the-converse-api-on-aws-bedrock-6c838c685ad9
Local files inspected
braintrust-sdk/src/main/java/dev/braintrust/instrumentation/InstrumentationSemConv.java— lines 339–429 (tagBedrockRequest/tagBedrockResponse), lines 460–501 (normalizeBedrockMessage: onlytext/toolUse/toolResult/imagehandled)braintrust-sdk/instrumentation/aws_bedrock_2_30_0/src/test/java/dev/braintrust/instrumentation/awsbedrock/v2_30_0/BraintrustAWSBedrockTest.java— no test exercises a reasoning/extended-thinking model response- Confirmed via issue #85 that this shared helper is treated as the "correct" reference implementation for non-streaming content-block normalization, but it does not cover
reasoningContent
- Ngôn ngữ chính
- Java
- Star
- 21
- Fork
- 5
- Merge trung bình
- 2 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 8
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của braintrustdata/braintrust-sdk-java
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Tất cả issue của braintrustdata/braintrust-sdk-java
Issue tương tự
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
apache/cloudstack#14222 ·
-
[BUG]茶杯方块在取茶时会引发崩溃 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Cannot differ own consent and managed consents in My Consents view and detailed consent view. Đang mở1.0.0-alpha2 Type/Improvement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
wso2/dpdp-accelerator#272 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
apache/rocketmq-dashboard#4860 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
infinispan/infinispan#18150 ·