Skip to content

feat(anthropic): add ChatAnthropicBedrock wrapper#35091

Merged
ccurme (ccurme) merged 21 commits intolangchain-ai:masterfrom
Nitin75408:Fixes/34757
Feb 20, 2026
Merged

feat(anthropic): add ChatAnthropicBedrock wrapper#35091
ccurme (ccurme) merged 21 commits intolangchain-ai:masterfrom
Nitin75408:Fixes/34757

Conversation

@Nitin75408
Copy link
Copy Markdown
Contributor

  1. PR title:feat(anthropic): add ChatAnthropicBedrock wrapper for AWS Bedrock with full feature parity

  2. PR description:

Adds ChatAnthropicBedrock to langchain-anthropic, wrapping Anthropic's AnthropicBedrock client to provide feature parity with ChatAnthropic using AWS credentials. This addresses gaps in ChatBedrockConverse (in langchain-aws), which uses AWS's Converse API and exposes only a subset of Anthropic features.
Fixes #34757

Changes
Core Implementation:
Added ChatAnthropicBedrock inheriting from ChatAnthropic to reuse generation, streaming, and tool binding
Uses AnthropicBedrock/AsyncAnthropicBedrock clients instead of the standard Anthropic client
Supports AWS credentials (access key, secret key, session token, region) with environment variable fallback

Shared Utilities:
Created langchain_anthropic/utils.py with resolve_aws_credentials() and create_bedrock_client_params() for reusable AWS credential handling

Extensibility Hook:
Added _get_ls_provider() to BaseChatModel to allow subclasses to customize LangSmith provider identification
Provider-agnostic and backward compatible

Features Supported
parallel_tool_calls control (enable/disable parallel tool execution)
thinking parameter (extended thinking mode)
strict tool schema validation
Configurable prompt caching (5m or 1h TTL)
Reliable streaming with tool use
Full LCEL compatibility

Files Modified
libs/partners/anthropic/langchain_anthropic/chat_models.py - Added ChatAnthropicBedrock class
libs/partners/anthropic/langchain_anthropic/init.py - Exported ChatAnthropicBedrock
libs/partners/anthropic/langchain_anthropic/utils.py - Added shared AWS credential utilities
libs/core/langchain_core/language_models/chat_models.py - Added _get_ls_provider() extensibility hook

Testing
Added 12 unit tests for utils functions covering credential resolution edge cases
Added 2 integration tests verifying ChatAnthropicBedrock uses utils correctly
Added 3 tests for the core extensibility hook
All existing tests pass; no breaking changes

Verification
Ran make format, make lint, and make test in libs/partners/anthropic and libs/core
Verified ChatAnthropicBedrock initializes with AWS credentials
Confirmed inheritance of ChatAnthropic methods (bind_tools, with_structured_output, streaming)
Tested _get_ls_provider() override for custom provider identification
Validated backward compatibility with existing ChatAnthropic usage

AI Disclosure
This PR was developed with assistance from AI coding tools. The implementation follows LangChain patterns, maintains backward compatibility, and includes tests.

Breaking Changes
None. This is an additive change that does not modify existing ChatAnthropic or ChatBedrockConverse behavior.

@github-actions github-actions bot added integration PR made that is related to a provider partner package integration core `langchain-core` package issues & PRs anthropic `langchain-anthropic` package issues & PRs external labels Feb 9, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Feb 9, 2026

Merging this PR will improve performance by 28.57%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚡ 7 improved benchmarks
✅ 9 untouched benchmarks
🆕 1 new benchmark
⏩ 19 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime test_import_time[tool] 542.3 ms 490.8 ms +10.49%
WallTime test_import_time[CallbackManager] 488.6 ms 443.4 ms +10.19%
WallTime test_import_time[PydanticOutputParser] 563.5 ms 505 ms +11.58%
WallTime test_import_time[LangChainTracer] 472.1 ms 421 ms +12.11%
WallTime test_async_callbacks_in_sync 23.5 ms 18.3 ms +28.57%
WallTime test_import_time[Runnable] 520.1 ms 471.7 ms +10.27%
WallTime test_import_time[Document] 191.6 ms 172.9 ms +10.86%
🆕 Simulation test_init_time N/A 1.1 ms N/A

Comparing Nitin75408:Fixes/34757 (296f1ae) with master (0382606)

Open in CodSpeed

Footnotes

  1. 19 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Nitin75408 NITIN Madan (Nitin75408) marked this pull request as draft February 10, 2026 17:42
@github-actions github-actions bot added the dependencies Pull requests that update a dependency file (e.g. `pyproject.toml` or `uv.lock`) label Feb 20, 2026
@ccurme ccurme (ccurme) self-assigned this Feb 20, 2026
@ccurme ccurme (ccurme) changed the title Added ChatAnthropicBedrock wrapper feat(anthropic): add ChatAnthropicBedrock wrapper Feb 20, 2026
@github-actions github-actions bot added the feature For PRs that implement a new feature; NOT A FEATURE REQUEST label Feb 20, 2026
@ccurme ccurme (ccurme) marked this pull request as ready for review February 20, 2026 17:56
@ccurme ccurme (ccurme) merged commit 63f3669 into langchain-ai:master Feb 20, 2026
102 checks passed
ccurme (ccurme) added a commit that referenced this pull request Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

anthropic `langchain-anthropic` package issues & PRs core `langchain-core` package issues & PRs dependencies Pull requests that update a dependency file (e.g. `pyproject.toml` or `uv.lock`) external feature For PRs that implement a new feature; NOT A FEATURE REQUEST integration PR made that is related to a provider partner package integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ChatAnthropicBedrock wrapper for full Anthropic SDK feature parity on AWS Bedrock

2 participants