Skip to content

feat(providers): add AWS Bedrock provider#1903

Merged
yinwm merged 1 commit intosipeed:mainfrom
loafoe:main
Mar 23, 2026
Merged

feat(providers): add AWS Bedrock provider#1903
yinwm merged 1 commit intosipeed:mainfrom
loafoe:main

Conversation

@loafoe
Copy link
Contributor

@loafoe loafoe commented Mar 22, 2026

📝 Description

Add support for AWS Bedrock as an LLM provider using the Converse API. The provider is behind a build tag to keep binary size small.

🗣️ Type of Change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 📖 Documentation update
  • ⚡ Code refactoring (no functional changes, no api changes)

🤖 AI Code Generation

  • 🤖 Fully AI-generated (100% AI, 0% Human)
  • 🛠️ Mostly AI-generated (AI draft, Human verified/modified)
  • 👨‍💻 Mostly Human-written (Human lead, AI assisted or none)

🔗 Related Issue

Refs #283
Implements #252

📚 Technical Context (Skip for Docs)

Example config:

  {"model": "bedrock/us.anthropic.claude-opus-4-5-20251101-v1:0", "api_base": "us-east-1"}

🧪 Test Environment

  • Hardware: Macbook Pro M3, Raspberry Pi 5
  • OS: Ubuntu 26.04, MacOS Tahoe
  • Model/Provider: Bedrock / Claude Opus 4.5

☑️ Checklist

  • My code/docs follow the style of this project.
  • I have performed a self-review of my own changes.
  • I have updated the documentation accordingly.

Copilot AI review requested due to automatic review settings March 22, 2026 21:12
@CLAassistant
Copy link

CLAassistant commented Mar 22, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds AWS Bedrock as a new LLM provider (Converse API) behind a bedrock build tag, wiring it into the provider factory and documenting configuration.

Changes:

  • Add bedrock protocol handling in CreateProviderFromConfig (region via api_base, AWS SDK credentials chain).
  • Implement Bedrock provider (Converse API) plus a non-tag stub provider that errors with build-tag guidance.
  • Update docs and Go module dependencies for AWS SDK v2 Bedrock Runtime.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pkg/providers/factory_provider.go Adds bedrock protocol branch to provider factory (region/options + provider initialization).
pkg/providers/bedrock/provider_stub.go Stub implementation for non-bedrock builds (returns build-tag error).
pkg/providers/bedrock/provider_bedrock.go Real Bedrock provider implementation using AWS SDK v2 Converse API.
go.mod Adds AWS SDK v2 dependencies needed for Bedrock Runtime client.
go.sum Adds checksums for newly introduced AWS SDK modules.
README.md Documents Bedrock provider, build tag requirement, and region configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sipeed-bot sipeed-bot bot added type: enhancement New feature or request domain: provider go Pull requests that update go code labels Mar 22, 2026
loafoe added a commit to loafoe/picoclaw that referenced this pull request Mar 22, 2026
Add AWS Bedrock provider using the Converse API with:
- Full tool/function calling support
- Image handling with proper base64 decoding
- Build tag gating (-tags bedrock)
- Comprehensive test coverage
- Timeout protection for AWS credential resolution

Addresses PR sipeed#1903 Copilot review feedback.
@loafoe loafoe requested a review from Copilot March 22, 2026 22:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

loafoe added a commit to loafoe/picoclaw that referenced this pull request Mar 22, 2026
Add AWS Bedrock provider using the Converse API with:
- Full tool/function calling support
- Image handling with proper base64 decoding
- Build tag gating (-tags bedrock)
- Comprehensive test coverage
- Timeout protection for AWS credential resolution
- Uses shared common.AsInt/AsFloat helpers

Addresses PR sipeed#1903 Copilot review feedback.
@loafoe loafoe requested a review from Copilot March 22, 2026 22:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

loafoe added a commit to loafoe/picoclaw that referenced this pull request Mar 22, 2026
Add AWS Bedrock provider using the Converse API with:
- Full tool/function calling support
- Image handling with proper base64 decoding and size limits
- Build tag gating (-tags bedrock)
- Comprehensive test coverage
- Timeout protection for AWS credential resolution
- Uses shared common.AsInt/AsFloat helpers
- Region validation (rejects URLs in api_base)

Addresses PR sipeed#1903 Copilot review feedback.
@loafoe loafoe requested a review from Copilot March 22, 2026 22:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

loafoe added a commit to loafoe/picoclaw that referenced this pull request Mar 22, 2026
Add AWS Bedrock provider using the Converse API with:
- Full tool/function calling support with Function fallback
- Image handling with proper base64 decoding and size limits
- Build tag gating (-tags bedrock)
- Comprehensive test coverage
- Timeout protection for AWS credential resolution
- Uses shared common.AsInt/AsFloat helpers
- Region validation (rejects URLs in api_base)

Addresses PR sipeed#1903 Copilot review feedback.
@loafoe loafoe requested a review from Copilot March 22, 2026 22:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

loafoe added a commit to loafoe/picoclaw that referenced this pull request Mar 23, 2026
Add AWS Bedrock provider using the Converse API with:
- Full tool/function calling support with Function fallback
- Image handling with proper base64 decoding and size limits
- Build tag gating (-tags bedrock)
- Comprehensive test coverage including factory tests
- Timeout protection for AWS credential resolution
- Uses shared common.AsInt/AsFloat helpers
- Region validation (rejects URLs in api_base)

Addresses PR sipeed#1903 Copilot review feedback.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

loafoe added a commit to loafoe/picoclaw that referenced this pull request Mar 23, 2026
Add AWS Bedrock provider using the Converse API with:
- Full tool/function calling support with Function fallback
- Image handling with proper base64 decoding and size limits
- Build tag gating (-tags bedrock)
- Comprehensive test coverage including factory tests
- Timeout protection for AWS credential resolution
- Uses shared common.AsInt/AsFloat helpers
- Proper endpoint configuration via api_base (URL or region name)
- Only sets ToolConfig when valid tools are present
- Consistent build-tag error messages in stub
- Region validation on provider creation
- Deterministic factory tests with dummy AWS env vars

api_base supports both:
- Region name: us-east-1 (sets both region and endpoint)
- Full endpoint URL (requires AWS_REGION separately)

Addresses PR sipeed#1903 Copilot review feedback.
@loafoe loafoe requested a review from Copilot March 23, 2026 10:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

loafoe added a commit to loafoe/picoclaw that referenced this pull request Mar 23, 2026
Add AWS Bedrock provider using the Converse API with:
- Full tool/function calling support with Function fallback
- Image handling with proper base64 decoding and size limits
- Build tag gating (-tags bedrock)
- Comprehensive test coverage including factory tests
- Timeout protection for AWS credential resolution
- Uses shared common.AsInt/AsFloat helpers
- Proper endpoint configuration via api_base (URL or region name)
- Only sets ToolConfig when valid tools are present
- Consistent build-tag error messages in stub
- Region validation on provider creation
- Deterministic factory tests with dummy AWS env vars
- AWS SDK endpoint resolution for all partitions (aws, aws-cn, aws-us-gov)

api_base supports both:
- Region name: us-east-1 (AWS SDK resolves endpoint for all partitions)
- Full endpoint URL (for custom endpoints or testing)

Addresses PR sipeed#1903 Copilot review feedback.
@loafoe loafoe requested a review from Copilot March 23, 2026 11:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@loafoe loafoe requested a review from Copilot March 23, 2026 11:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@loafoe
Copy link
Contributor Author

loafoe commented Mar 23, 2026

@jmahotiedu @Leeaandrob @shresthapranesh with #213 landed added AWS Bedrock support. Tested with different models in different AWS regions, also went through several Copilot review iterations to align with existing code. Please consider reviewing / merging, thanks for this awesome project!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Add support for AWS Bedrock as an LLM provider using the Converse API.
The implementation is behind a build tag (-tags bedrock) to keep the
default binary size small.

Features:
- AWS SDK v2 with automatic credential chain (env vars, profiles, IAM roles)
- Converse API for unified access to Claude, Llama, Mistral models
- Tool/function calling support with proper document handling
- Image support with base64 decoding and size limits
- Request timeout configuration
- Region validation and endpoint resolution for all AWS partitions

Usage:
  go build -tags bedrock
  model: bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0
  api_base: us-east-1  (or full endpoint URL)
Copy link
Collaborator

@yinwm yinwm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Review Summary:

  • Clean implementation with proper build tag separation ( / )
  • AWS SDK v2 integration with automatic credential chain
  • Excellent test coverage (~95%) including edge cases
  • Correct handling of Bedrock-specific requirements (tool results merging)
  • All CI checks passed

Minor notes (non-blocking):

  • Binary size increases ~10MB when built with (expected for AWS SDK)
  • Consider returning error instead of silent skip for oversized images (future improvement)

Thanks for the contribution!

Copy link
Collaborator

@yinwm yinwm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Review Summary:

  • Clean implementation with proper build tag separation
  • AWS SDK v2 integration with automatic credential chain
  • Excellent test coverage (~95%) including edge cases
  • Correct handling of Bedrock-specific requirements (tool results merging)
  • All CI checks passed

Minor notes (non-blocking):

  • Binary size increases ~10MB when built with bedrock tag (expected for AWS SDK)
  • Consider returning error instead of silent skip for oversized images (future improvement)

Thanks for the contribution!

@Orgmar
Copy link
Contributor

Orgmar commented Mar 24, 2026

@loafoe Awesome work bringing AWS Bedrock support to PicoClaw! Using the Converse API and keeping it behind a build tag to avoid bloating the binary is a thoughtful design choice. Testing on both Mac and Raspberry Pi is a nice touch too. This has been requested since #283, so a lot of users will appreciate it.

We have a PicoClaw Dev Group on Discord where contributors connect and collaborate. If you'd like to join, send an email to support@sipeed.com with subject [Join PicoClaw Dev Group] loafoe and we'll send you the invite link!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: provider go Pull requests that update go code type: enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants