feat(anthropic): add ChatAnthropicBedrock wrapper#35091
Merged
ccurme (ccurme) merged 21 commits intolangchain-ai:masterfrom Feb 20, 2026
Merged
feat(anthropic): add ChatAnthropicBedrock wrapper#35091ccurme (ccurme) merged 21 commits intolangchain-ai:masterfrom
ccurme (ccurme) merged 21 commits intolangchain-ai:masterfrom
Conversation
Merging this PR will improve performance by 28.57%
|
| 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)
Footnotes
-
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. ↩
# Conflicts: # libs/partners/anthropic/langchain_anthropic/__init__.py # libs/partners/anthropic/tests/unit_tests/test_chat_models.py
ccurme (ccurme)
added a commit
that referenced
this pull request
Feb 20, 2026
This reverts commit 63f3669.
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.
PR title:feat(anthropic): add ChatAnthropicBedrock wrapper for AWS Bedrock with full feature parity
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.