Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[bot] Bedrock ConverseStream drops tool use and non-text content blocks in streaming spans

Đang mở
#85 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
64/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
aws, java
Lĩnh vực
cloud, observability

Hướng nghiên cứu

Bắt đầu với TeeingSubscriber.onNext, parseDeltaText và buildConverseJson trong braintrust-sdk/instrumentation/aws_bedrock_2_30_0/src/main/java/dev/braintrust/instrumentation/awsbedrock/v2_30_0/BraintrustBedrockInterceptor.java. So sánh cách xử lý sự kiện streaming với normalizeBedrockMessage() trong braintrust-sdk/src/main/java/dev/braintrust/instrumentation/InstrumentationSemConv.java và xem lại các bài kiểm thử Bedrock hiện có. Hoàn thành khi nội dung tool-use trong streaming, các mã định danh, tên và dữ liệu đầu vào được biểu diễn trong đầu ra của span, với coverage trong BraintrustAWSBedrockTest.java.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

The Bedrock ConverseStream instrumentation in TeeingSubscriber only accumulates delta.text from contentBlockDelta events. When the model returns tool use content blocks during streaming (a documented and supported Bedrock feature), the tool call data is silently dropped from the span output.

Non-streaming Converse calls handle tool use correctly — normalizeBedrockMessage() in InstrumentationSemConv already recognizes toolUse, toolResult, and image content block types and adds appropriate type annotations. The gap is exclusively in the streaming path.

What is missing

1. TeeingSubscriber only parses text deltas (lines 273–289)
case "contentBlockDelta" -> {
    String t = parseDeltaText(payload);   // only looks for delta.text
    if (t != null) {
        text.append(t);
        // ...
    }
}

parseDeltaText() (lines 322–339) searches exclusively for delta.text. Bedrock ConverseStream sends delta.toolUse for tool use blocks (containing incremental input JSON), which is silently ignored.

2. contentBlockStart events are not handled

The TeeingSubscriber switch (lines 273–289) has no case for contentBlockStart. This event carries toolUse.toolUseId and toolUse.name — metadata needed to reconstruct the tool call. Without it, even if tool use deltas were captured, the tool name and ID would be lost.

3. buildConverseJson always produces a single text block (lines 385–410)
gen.writeArrayFieldStart("content");
gen.writeStartObject();
gen.writeStringField("text", text);   // always one text block
gen.writeEndObject();
gen.writeEndArray();

The synthetic response JSON always contains exactly one {"text": "..."} content block, regardless of what the model actually returned. When the model requests a tool call, the span output will show empty text instead of the tool invocation.

Impact

When a streaming Bedrock call triggers tool use (common in agentic workflows):

  • The span's output_json contains [{"role":"assistant","content":[{"text":"","type":"text"}]}] — as if the model returned nothing
  • The stopReason is captured as "tool_use", contradicting the empty output
  • Tool call names, IDs, and argument JSON are permanently lost from the trace
  • Non-streaming Converse calls with tool use are correctly captured

Braintrust docs status

Upstream sources

Local files inspected

  • braintrust-sdk/instrumentation/aws_bedrock_2_30_0/src/main/java/dev/braintrust/instrumentation/awsbedrock/v2_30_0/BraintrustBedrockInterceptor.java — lines 273–289 (TeeingSubscriber.onNext: only contentBlockDelta→text, messageStop, metadata handled; no contentBlockStart), lines 322–339 (parseDeltaText: only delta.text), lines 385–410 (buildConverseJson: hardcoded single text block)
  • braintrust-sdk/src/main/java/dev/braintrust/instrumentation/InstrumentationSemConv.java — lines 400–434 (normalizeBedrockMessage: non-streaming path correctly handles toolUse, toolResult, image content block types)
  • braintrust-sdk/instrumentation/aws_bedrock_2_30_0/src/test/java/dev/braintrust/instrumentation/awsbedrock/v2_30_0/BraintrustAWSBedrockTest.java — no streaming test exercises tool use responses
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

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của braintrustdata/braintrust-sdk-java

Tất cả issue của braintrustdata/braintrust-sdk-java

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.