Skip to content

fix(bedrock_runtime): improve metrics, tools, and attachments on spans#584

Merged
Abhijeet Prasad (AbhiPrasad) merged 2 commits into
mainfrom
fix/bedrock-runtime-spec-compliance
Jul 17, 2026
Merged

fix(bedrock_runtime): improve metrics, tools, and attachments on spans#584
Abhijeet Prasad (AbhiPrasad) merged 2 commits into
mainfrom
fix/bedrock-runtime-spec-compliance

Conversation

@starfolkai

@starfolkai starfolkai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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 (no bt_safe_deep_copy, no json.dumps(json.loads(...)) round-trips, dict(...) copies only where mutation is needed) — no changes needed on that axis.

Changes

  • bedrock_latency_msmetadata. It isn't on the spec's metric allowlist. Applied to both non-streaming Converse and _TracedConverseStream._finish.
  • toolConfig → OpenAI-shaped metadata.tools + metadata.tool_choice. Was previously dumped as raw metadata.tool_config. Each {"toolSpec": {name, description, inputSchema.json}} becomes {"type": "function", "function": {name, description, parameters}}; toolChoice auto/any/{tool: {name}} maps to OpenAI's "auto" / "required" / {"type": "function", "function": {"name": ...}}.
  • Image / document content parts now emit spec shapes and drop the redundant source blob after materializing into an Attachment:
    • image: {"type": "image_url", "image_url": {"url": Attachment}, "format": ...}
    • document: {"type": "file", "file": {"file_data": Attachment, "filename": ...}, "format": ..., "name": ..., "citations": ...}
    • Provider-native s3Location references (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.
  • Three new VCR-backed tests (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

starfolkbot and others added 2 commits July 16, 2026 22:37
… 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>
@AbhiPrasad Abhijeet Prasad (AbhiPrasad) changed the title fix(bedrock_runtime): align spans with SKILL.md — tools, attachments, latency fix(bedrock_runtime): improve metrics, tools, and attachments on spans Jul 17, 2026
@AbhiPrasad Abhijeet Prasad (AbhiPrasad) marked this pull request as ready for review July 17, 2026 00:14
@AbhiPrasad Abhijeet Prasad (AbhiPrasad) merged commit b49e716 into main Jul 17, 2026
82 checks passed
@AbhiPrasad Abhijeet Prasad (AbhiPrasad) deleted the fix/bedrock-runtime-spec-compliance branch July 17, 2026 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants