fix(bedrock_runtime): improve metrics, tools, and attachments on spans#584
Merged
Abhijeet Prasad (AbhiPrasad) merged 2 commits intoJul 17, 2026
Merged
Conversation
… latency
- `bedrock_latency_ms` moves from `metrics` to `metadata` since it's not
on the spec's metric allowlist.
- `toolConfig` is normalized into OpenAI-shaped `metadata.tools` and
`metadata.tool_choice` (was previously dumped as a raw
`metadata.tool_config` blob).
- Image and document content parts now emit the spec shapes
(`{"type": "image_url", "image_url": {"url": Attachment}}` and
`{"type": "file", "file": {"file_data": Attachment, "filename": ...}}`)
and drop the redundant `source` field once the payload has been
materialized into an `Attachment`. Provider-native shapes
(e.g. `s3Location` refs) still pass through unchanged.
- Adds VCR-backed tests for tool use, image input, and document input
(cassettes still to be recorded).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Abhijeet Prasad (AbhiPrasad)
approved these changes
Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Audit of
py/src/braintrust/integrations/bedrock_runtime/against.agents/skills/sdk-integrations/SKILL.md. Three spec deltas fixed; the tracing code was already clean of excess serialization (nobt_safe_deep_copy, nojson.dumps(json.loads(...))round-trips,dict(...)copies only where mutation is needed) — no changes needed on that axis.Changes
bedrock_latency_ms→metadata. It isn't on the spec's metric allowlist. Applied to both non-streaming Converse and_TracedConverseStream._finish.toolConfig→ OpenAI-shapedmetadata.tools+metadata.tool_choice. Was previously dumped as rawmetadata.tool_config. Each{"toolSpec": {name, description, inputSchema.json}}becomes{"type": "function", "function": {name, description, parameters}};toolChoiceauto/any/{tool: {name}}maps to OpenAI's"auto"/"required"/{"type": "function", "function": {"name": ...}}.sourceblob after materializing into anAttachment:{"type": "image_url", "image_url": {"url": Attachment}, "format": ...}{"type": "file", "file": {"file_data": Attachment, "filename": ...}, "format": ..., "name": ..., "citations": ...}s3Locationreferences (no inline bytes) still pass through unchanged.Test plan
nox -s "test_bedrock_runtime(latest)"— 9 existing tests pass.nox -s "test_bedrock_runtime(1.34.116)"— 9 existing tests pass on the min matrix pin.nox -s pylint— clean.test_wrap_bedrock_converse_normalizes_tool_config_and_output,test_wrap_bedrock_converse_with_image_input_materializes_attachment,test_wrap_bedrock_converse_with_document_input_materializes_attachment) are added but need cassettes. You'll record these.🤖 Generated with Claude Code
Slack thread
Created by abhijeet