[bot] Bedrock Converse/ConverseStream requests: toolConfig (tool definitions) never captured in span metadata

Đang mở Phù hợp với người mới
#158 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ó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/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
api, backend

Hướng nghiên cứu

Bắt đầu trong braintrust-sdk/src/main/java/dev/braintrust/instrumentation/InstrumentationSemConv.java tại tagBedrockRequest, sau đó kiểm tra BraintrustBedrockInterceptor.java và BraintrustAWSBedrockTest.java. Bổ sung coverage cho việc capture các request Converse và ConverseStream có toolConfig, đồng thời xác minh rằng các định nghĩa tool và chính sách lựa chọn tool xuất hiện trong metadata được capture hoặc input_json.

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

Mô tả

Summary

InstrumentationSemConv.tagBedrockRequest() extracts inferenceConfig (maxTokens/temperature/topP/stopSequences), system, and messages from the Bedrock Converse/ConverseStream request body, but never reads the top-level toolConfig field. toolConfig carries the tool definitions and tool-choice policy sent to the model — a core, documented part of the Converse API request — and is silently dropped from every Bedrock LLM span's braintrust.metadata/braintrust.input_json, for both streaming and non-streaming calls.

This is a request-side gap and is distinct from issue #85 (which covers the response-side streaming reconstruction dropping tool-use content blocks in TeeingSubscriber/buildConverseJson). Even for non-streaming Converse calls where the response-side tool use is captured correctly by normalizeBedrockMessage(), the request never shows what tools were offered to the model or what tool-choice policy was set.

What is missing

In tagBedrockRequest() (InstrumentationSemConv.java, lines 339-396):

if (requestBody != null) {
    JsonNode requestJson = BraintrustJsonMapper.get().readTree(requestBody);
    if (requestJson.has("inferenceConfig")) { ... }   // handled
    if (requestJson.has("messages")) { ... }           // handled
}

There is no if (requestJson.has("toolConfig")) branch anywhere in this method. The Converse/ConverseStream request body's toolConfig object — containing tools (an array of toolSpec definitions with name/description/inputSchema) and toolChoice (auto/any/{tool: {name}}) — is read from requestBody but never surfaced into metadata or input_json. A trace of a tool-enabled Bedrock call shows the conversation and inference params but gives no visibility into which tools were available or how tool selection was constrained, even though the model's resulting stopReason: "tool_use" and tool call are otherwise correctly displayed.

Braintrust docs status

Upstream sources

Local files inspected

  • braintrust-sdk/src/main/java/dev/braintrust/instrumentation/InstrumentationSemConv.java — lines 339-396 (tagBedrockRequest: reads inferenceConfig, system, messages; no toolConfig handling anywhere in the method or file)
  • braintrust-sdk/instrumentation/aws_bedrock_2_30_0/src/main/java/dev/braintrust/instrumentation/awsbedrock/v2_30_0/BraintrustBedrockInterceptor.java — passes the raw request body through to tagBedrockRequest; no separate toolConfig handling
  • braintrust-sdk/instrumentation/aws_bedrock_2_30_0/src/test/java/dev/braintrust/instrumentation/awsbedrock/v2_30_0/BraintrustAWSBedrockTest.java — no test asserts on toolConfig appearing in captured metadata
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.