feat: AWS Bedrock provider adapter - #203
Open
NahumKorda wants to merge 2 commits into
Open
Conversation
Add a `bedrock` provider type that runs OpenAnt scans against Claude
models on AWS Bedrock with native AWS credentials — no proxy needed.
Bedrock is on the README roadmap ("More provider adapters"); this
implements it Python-only, with no config-schema or Go CLI changes.
Design: the registry constructs every adapter as
`cls(api_key=..., base_url=...)`, and AWS needs SigV4 credentials plus
a region, which don't fit that signature. Rather than widening
ProviderConfig (and touching Go config parsing), BedrockAdapter keeps
the same constructor shape and delegates credentials and region to the
SDK's standard AWS chain (AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY env
vars or ~/.aws profile; AWS_REGION env, then boto3 session). `api_key`
is ignored with a one-time warning; `base_url` still works as a full
endpoint override (VPC endpoints, gateways).
Bedrock speaks the same Messages API through the same `anthropic` SDK
types (`anthropic.AnthropicBedrock`), so the adapter reuses the
Anthropic adapter's translation layer — blocks, stop reasons, and the
refusal -> LLMRefusalError guard — parameterizing only the warning
attribution. Bedrock-specific deltas:
- 403 AccessDenied -> LLMAuthError with a Bedrock "Model access" hint
(the usual cause is a model not enabled for the account/region)
- 400 "model identifier is invalid" -> LLMNotFoundError (Bedrock
reports bad model IDs as ValidationException, not 404)
- SDK's bare no-credentials RuntimeError -> LLMAuthError
- throttling 429s report to the global RateLimiter like the reference
adapter; the 529 branch is kept harmless for Anthropic-compat
gateways behind base_url
Model IDs are cross-region inference profiles. config/models.json
gains six bedrock records (us./global. families for opus-4-8,
sonnet-4-6, haiku-4-5) with IDs verified against a live Bedrock
account via list-inference-profiles; prices mirror the direct
Anthropic API records. Note opus-4-8 and sonnet-4-6 profiles carry no
-v1:0 suffix.
Tests: bedrock row in the contract-test ADAPTERS fixture with a
scenario factory stubbing AnthropicBedrock, plus 15 Bedrock-specific
tests (constructor plumbing, verbatim profile IDs, error mapping,
rate-limiter coordination). Live-validated: messages.create round-trip
confirmed against us.anthropic.claude-sonnet-4-6 and
global.anthropic.claude-haiku-4-5-20251001-v1:0 in us-east-1.
Go wizard support (setup.go) is deliberately out of scope; a
hand-authored config works, as the README documents.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
NahumKorda
requested review from
dgeyshis,
gadievron,
shahar-davidson and
sounil
as code owners
August 1, 2026 10:05
Adds utilities/llm/providers/BEDROCK.md — prerequisites (model access + minimal IAM policy), the credential/region resolution chain, full config.json example, the inference-profile ID conventions and their suffix inconsistency, cost accounting, an error/troubleshooting table, and current limitations — and links it from the README's shipped-adapters table. Placed next to the adapter code (the repo convention, cf. the parser PARSER_PIPELINE.md files) because docs/ is gitignored. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
Added a detailed usage guide in 733d628: |
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.
Adds
bedrockas a first-class provider type — Claude on AWS Bedrock — per the roadmap's "More provider adapters" item; related to #9 and the pricing-accounting invariants of #65.Design
The registry constructs every adapter as
adapter_cls(api_key=..., base_url=...), andProviderConfigdeliberately has no other fields. Rather than widening that surface for one provider,BedrockAdapterkeeps the two-kwarg constructor and delegates credentials and region entirely to the AWS SDK chain (AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEYenv vars,~/.awsprofiles,AWS_REGION) viaanthropic.AnthropicBedrock— soopenantauthenticates exactly like theawsCLI on the same machine, and the diff stays Python-only (no Go or config-schema changes).api_keyis accepted-and-ignored with a one-time warning, since Bedrock has no API-key auth in the pinned SDK.The wire format is Anthropic's, so the adapter reuses the Anthropic adapter's translation helpers;
anthropic.py's shared warnings take anadapter=name so reused code attributes messages correctly.Bedrock-specific behavior
us.anthropic.claude-sonnet-4-6,global.anthropic.claude-haiku-4-5-20251001-v1:0, ...), passed through verbatim; IDs and pricing records inconfig/models.jsonwere verified against a live Bedrock account vialist-inference-profiles(us-east-1), not derived from naming conventions — the-v1:0suffix is not uniform across profiles.LLMAuthErrorwith a "Model access" hint (the most common first-run failure: the model isn't enabled in the Bedrock console).LLMNotFoundError(Bedrock does not 404 unknown models), so the registry's init-timevalidate()reports a typo'd profile as such.RuntimeError("could not resolve credentials...")from the SigV4 signer →LLMAuthErrorwith a pointer at the env vars; unrelated RuntimeErrors still propagate.RateLimiter, same as the reference adapters.Testing
validate()and text completions onus.anthropic.claude-sonnet-4-6andglobal.anthropic.claude-haiku-4-5-20251001-v1:0.Notes for reviewers
openant setup llm) is intentionally out of scope per the "optional" checklist item; the README documents hand-authored config for now.docs/features/llm-providers/HOW_TO_ADD_AN_ADAPTER.mdis dead in the current tree (the file doesn't exist); left as-is here since it predates this PR, but happy to fix it in this PR if you'd like.🤖 Generated with Claude Code