Skip to content

Anthropic model-info lookup does not resolve AWS Bedrock / cross-region inference model IDs #7833

Description

@kimnamu

Thanks for AutoGen and the Anthropic-on-Bedrock client. (Filing this as a small bug fix, in keeping with the project's maintenance-mode scope — not a feature request.)

What happened?

While using AnthropicBedrockChatCompletionClient, the model-info auto-detection can't resolve Bedrock-style model IDs.

Repro (no network / keys needed):

from autogen_ext.models.anthropic import _model_info
_model_info.get_info("us.anthropic.claude-3-5-sonnet-20240620-v1:0")
# KeyError: "Model 'us.anthropic.claude-3-5-sonnet-20240620-v1:0' not found in model info"
_model_info.get_token_limit("anthropic.claude-3-5-sonnet-20240620-v1:0")
# 100000  (fallback; the matching table entry is 200000)

Cause

The matcher in python/packages/autogen-ext/src/autogen_ext/models/anthropic/_model_info.py:149 is prefix-anchored (model.startswith(model_id.split("-2")[0])), so Bedrock provider/region prefixes (anthropic., us./eu./apac./global.anthropic.) and the -vN:M suffix never match. The Bedrock docstring example (_anthropic_client.py:1318) and the serialization test both pass model_info=ModelInfo(...) manually — a workaround for exactly this.

Scope note

The table values (context windows etc.) are a separate data-correctness concern; this is only about ID resolution. I have a minimal fix (a shared normalize helper) + a no-network regression test ready, happy to open a PR.

Activity

  1. Functionhx commented on Jul 9, 2026

    @Functionhx

    Added _normalize_model_id to strip Bedrock prefixes and version suffixes before model info lookup. Also filled in missing Claude 4 token limits. PR ready.

  2. added a commit that references this issue on Sep 2, 2026
    07ea995
  3. kimnamu commented on Sep 30, 2026

    @kimnamu
    Author

    Thanks Eric Zhu (@ekzhu) for all the time you've put into autogen's model clients, including merging the Anthropic-on-Bedrock work in #6170 and #6979. This issue now has four open PRs for the same lookup fix (one of them is mine), so I've put them in one table to make it easier to pick one.

    PR Author New tests (file result) Base Workflow runs on head Also in the PR
    #7834 (mine) kimnamu 5 (23 passed) main @ 027ecf0 0 none
    #7886 C1-BA-B1-F3 7 in a new test file (25 passed) main @ 027ecf0 0 none
    #7930 HumphreySun98 3 (21 passed) main @ 027ecf0 7, waiting for approval adds the missing Claude 4 entries to _MODEL_TOKEN_LIMITS
    #8144 wasim-builds 4 (22 passed) main @ 027ecf0 7, waiting for approval also targets #7867 (tool output serialization) and #7768 (trailing assistant messages)

    All four sit on current main with no conflicts, and all four fix the reported KeyError. In my run the visible difference was the Claude 4 token limit, where only #7930 returns 200000:

    get_info / get_token_limit("us.anthropic.claude-sonnet-4-20250514-v1:0")
    main @ 027ecf0   KeyError          100000
    #7834            claude-4-sonnet   100000
    #7886            claude-4-sonnet   100000
    #7930            claude-4-sonnet   200000
    #8144            claude-4-sonnet   100000
    

    ErenAta16 also compared #7834, #7886 and #7930 head to head in a review on #7930, including a us-gov. prefix case I haven't repeated here.

    When you have a moment, could you say which one you'd like to take forward? If this isn't a priority right now, or you'd rather go with one of the others, tell me and I'll close #7834 to keep your queue clean.

    How this was run

    Each PR's _model_info.py was loaded from its head commit and called with the same IDs. Test results are tests/models/test_anthropic_model_client.py (plus test_anthropic_model_info.py for #7886) in python/packages/autogen-ext, run without API credentials: 18 passed on main, 20 skipped on every branch.

    id                                               main                       #7834                      #7886                      #7930                      #8144
    anthropic.claude-3-5-sonnet-20240620-v1:0        KeyError, 100000           claude-3-5-sonnet, 200000  claude-3-5-sonnet, 200000  claude-3-5-sonnet, 200000  claude-3-5-sonnet, 200000
    global.anthropic.claude-sonnet-4-20250514-v1:0   KeyError, 100000           claude-4-sonnet, 100000    claude-4-sonnet, 100000    claude-4-sonnet, 200000    claude-4-sonnet, 100000
    claude-3-5-sonnet-20240620                       claude-3-5-sonnet, 200000  claude-3-5-sonnet, 200000  claude-3-5-sonnet, 200000  claude-3-5-sonnet, 200000  claude-3-5-sonnet, 200000
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions