Skip to content

Conversation

@mfenderov
Copy link

@mfenderov mfenderov commented Dec 6, 2025

Add AWS Bedrock provider using the Converse API. Supports all Bedrock models (Claude, Titan, Llama, Mistral) with AWS credential chain and Bedrock API key authentication.

models:
  claude:
    provider: bedrock
    model: global.anthropic.claude-sonnet-4-5-20250929-v1:0
    provider_opts:
      region: us-east-1

This is an initial implementation to keep PR size manageable. Future additions: prompt caching, IAM policy examples, troubleshooting docs.

P.S.
There's an existing PR #542 that also adds Bedrock support, but there's been no movement in more than a month.

mfenderov and others added 3 commits December 6, 2025 11:46
Implement Bedrock provider using AWS SDK v2 with:
- Default credential chain (env vars, shared config, IAM roles)
- Support for all Bedrock models via Converse API
- Cross-region inference profiles
- provider_opts: region, profile, role_arn, external_id, endpoint_url
- Streaming responses with tool calling support

New files:
- pkg/model/provider/bedrock/client.go - Main client
- pkg/model/provider/bedrock/convert.go - Message/tool conversion
- pkg/model/provider/bedrock/adapter.go - Stream adapter
- pkg/model/provider/bedrock/client_test.go - Unit tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add prerequisites section with link to Bedrock Console
- Link to AWS SDK credential chain documentation
- Clarify authentication flow

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add bearer token auth support (AWS_BEARER_TOKEN_BEDROCK or api_key provider_opt)
- Update default model to global.anthropic.claude-sonnet-4-5-20250929-v1:0
- Add inference profile prefix documentation (global., us., eu.)
- Add unit test for bearer token transport
- Update docs with API key authentication section

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mfenderov mfenderov marked this pull request as ready for review December 6, 2025 13:00
@mfenderov mfenderov requested a review from a team as a code owner December 6, 2025 13:00
mfenderov and others added 2 commits December 6, 2025 14:25
Bedrock's Converse API requires that multiple tool results be grouped
into a single user message. The previous implementation created
separate messages for each tool result, causing ValidationException:
"Expected toolResult blocks at messages.N.content for the following Ids"

Changes:
- Modified loop to use index-based iteration for index manipulation
- Added grouping logic for consecutive MessageRoleTool messages
- Added comprehensive test for multi-tool result scenarios

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add 7 new tests to improve coverage:
- TestConvertImageURL_NonDataURL
- TestConvertImageURL_InvalidDataURLFormat
- TestConvertImageURL_InvalidBase64
- TestConvertImageURL_AllFormats (table-driven)
- TestConvertImageURL_ValidImage
- TestNewClient_NilConfig
- TestNewClient_WrongProvider

These tests cover critical error paths identified in code review.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mfenderov mfenderov force-pushed the feature/bedrock-provider branch from 254c74e to d657e41 Compare December 6, 2025 13:48
Add pr-reviewer-bedrock.yaml - a multi-agent PR review toolkit that
mirrors Claude Code's pr-review-toolkit plugin with 6 specialized agents:
- code-reviewer: Guidelines compliance and bug detection
- silent-failure-hunter: Error handling audit
- code-simplifier: Code simplification
- comment-analyzer: Comment quality analysis
- test-analyzer: Test coverage analysis
- type-analyzer: Type design and invariants

Also adds 8 new tests for Bedrock provider:
- buildAWSConfig tests (region precedence, env vs provider_opts)
- NewClient validation tests (valid config, bearer token paths)
- getProviderOpt type mismatch edge cases
- Interface compliance assertion

Test coverage: Bedrock now at 58% (highest of all providers).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

1 participant