crewai - ✅(Solved) Fix [FEATURE] Support Bedrock's Anthropic V4 LLM's [1 pull requests, 2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
crewAIInc/crewAI#4700Fetched 2026-04-08 00:40:35
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
0
Timeline (top)
commented ×2labeled ×2cross-referenced ×1referenced ×1

Fix Action

Fixed

PR fix notes

PR #4701: feat(bedrock): add support for Anthropic Claude V4 models

Description (problem / solution / changelog)

feat(bedrock): add support for Anthropic Claude V4 models

Summary

Adds support for AWS Bedrock's Anthropic Claude V4 model family (Claude Sonnet 4, Opus 4, Opus 4.1, Haiku 4.5, Sonnet 4.5, Opus 4.5). These models use the same Converse API as V3, so the changes are primarily capability detection and configuration — no new API implementation was needed.

Key changes:

  • _strip_region_prefix() static method on BedrockCompletion — strips us./eu./apac./global. region qualifiers from model IDs so capability lookups work uniformly regardless of cross-region inference prefix.
  • get_context_window_size() — added V4 model prefix entries (all 200K tokens), now uses _strip_region_prefix for matching.
  • supports_multimodal() — refactored to use _strip_region_prefix instead of hardcoding region-prefixed model names. Added V4 model prefixes.
  • _is_nova_model() — also updated to use _strip_region_prefix for consistency (minor behavioral change: substring match → prefix match after stripping).
  • LLM_CONTEXT_WINDOW_SIZES in llm.py — added V4 model IDs with us., eu., apac., and bare prefixes.
  • 11 new tests covering V4 model detection, context windows, multimodal support, region prefix handling, function calling, inference config, mocked API calls, and a V3 regression test.

Closes #4700

Review & Testing Checklist for Human

  • Prefix matching order in get_context_window_size(): "anthropic.claude-opus-4" will match opus-4-1 and opus-4-5 via startswith. This is currently fine since all have 200K context, but the pattern is fragile if future models diverge. Verify this is acceptable.
  • EU/APAC region coverage in LLM_CONTEXT_WINDOW_SIZES: The eu. and apac. sections have fewer V4 entries than us. — confirm this matches actual AWS regional availability rather than being an omission.
  • supports_multimodal() refactor: Previously hardcoded us.amazon.nova-* for Nova vision support; now uses _strip_region_prefix which means eu./apac./global. Nova models are also covered. Verify this is a desired side-effect fix.
  • Real Bedrock API test: All 11 new tests use mocks. If you have AWS credentials, try instantiating LLM(model="bedrock/anthropic.claude-sonnet-4-20250514-v1:0") and calling it against real Bedrock to confirm the model IDs are correct.

Test plan

  1. Run the full bedrock test suite: uv run pytest tests/llms/bedrock/test_bedrock.py -vv (39 passed ✅)
  2. Verify lint passes: uv run ruff check lib/crewai/src/crewai/llm.py lib/crewai/src/crewai/llms/providers/bedrock/completion.py lib/crewai/tests/llms/bedrock/test_bedrock.py (all checks passed ✅)
  3. Optional: Test against real AWS Bedrock with a V4 model ID to confirm the implementation actually works end-to-end.

Notes

<!-- CURSOR_SUMMARY -->

[!NOTE] Medium Risk Updates Bedrock model capability detection (context window, multimodal, Nova identification) and introduces region-prefix normalization, which could subtly change behavior for existing region-prefixed model IDs if matching assumptions were relied on.

Overview Adds recognition of Anthropic Claude 4.x Bedrock model IDs (including us./eu./apac./global.-prefixed variants) and maps them to a 200K context window in LLM_CONTEXT_WINDOW_SIZES.

In BedrockCompletion, introduces _strip_region_prefix() and uses it to make get_context_window_size(), supports_multimodal(), and _is_nova_model() work consistently across region-prefixed model IDs; multimodal detection is expanded to include Claude 4.x and simplified to base-model prefixes.

Extends test_bedrock.py with a focused suite covering Claude 4.x routing, context window sizing, multimodal support, region-prefix handling, inference config, mocked calls, Nova detection with prefixes, and a Claude 3.x regression check.

<sup>Written by Cursor Bugbot for commit d0da1149f0dc88554a6477c0fc64e25826e768fb. This will update automatically on new commits. Configure here.</sup>

<!-- /CURSOR_SUMMARY -->

Changed files

  • lib/crewai/src/crewai/llm.py (modified, +25/-0)
  • lib/crewai/src/crewai/llms/providers/bedrock/completion.py (modified, +47/-11)
  • lib/crewai/tests/llms/bedrock/test_bedrock.py (modified, +219/-0)
RAW_BUFFERClick to expand / collapse

Feature Area

Core functionality

Is your feature request related to a an existing bug? Please link it here.

Bedrock's Anthropic V3 models or no longer available at AWS (only for legacy customers). The V4 models aren't available in CrewAI

Describe the solution you'd like

To be able to use the Bedrock Anthropic V4 models as the LLM in my crews

Describe alternatives you've considered

No response

Additional context

No response

Willingness to Contribute

Yes, I'd be happy to submit a pull request

extent analysis

Fix Plan

To use Bedrock Anthropic V4 models as the LLM in CrewAI, we need to integrate the V4 models into the existing CrewAI infrastructure. Here are the steps:

  • Update the model configuration to include the V4 models
  • Implement a compatibility layer to handle any differences between the V3 and V4 models
  • Test the integration to ensure seamless functionality

Example Code

# models.py
class BedrockModel:
    def __init__(self, model_version):
        self.model_version = model_version

    def get_model(self):
        if self.model_version == "V3":
            # Return V3 model
            return BedrockV3Model()
        elif self.model_version == "V4":
            # Return V4 model
            return BedrockV4Model()
        else:
            raise ValueError("Invalid model version")

class BedrockV4Model:
    def __init__(self):
        # Initialize V4 model
        self.model = AnthropicV4Model()

    def predict(self, input_text):
        # Use V4 model for prediction
        return self.model.predict(input_text)

Verification

To verify the fix, test the CrewAI application with the integrated V4 models. Ensure that the models are correctly loaded and used for predictions.

Extra Tips

  • Ensure that the V4 models are compatible with the existing CrewAI infrastructure
  • Test the integration thoroughly to avoid any regressions
  • Consider adding logging and monitoring to track the performance of the V4 models

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING