Skip to content

fix: resolve Bedrock and cross-region Anthropic model IDs in model info lookup - #7834

Closed
Lucas Kim (kimnamu) wants to merge 1 commit into
microsoft:mainfrom
kimnamu:fix/anthropic-bedrock-model-id-resolution
Closed

Lucas Kim (kimnamu) wants to merge 1 commit into
microsoft:mainfrom
kimnamu:fix/anthropic-bedrock-model-id-resolution

Conversation

@kimnamu

Copy link
Copy Markdown

Thanks to the maintainers. Small bug fix (no new features — consistent with maintenance-mode scope). This fills a gap so Bedrock-hosted Claude IDs resolve like the native ones — native Anthropic IDs already resolve; only the Bedrock/cross-region forms were missing.

Fixes #7833.

Problem / cause

The matcher in _model_info.py is prefix-anchored (model.startswith(model_id.split("-2")[0])), so anthropic. / us./eu./apac./global.anthropic. prefixes and the -vN:M suffix never match → get_info raises KeyError, get_token_limit silently returns the 100000 fallback.

Change

A small shared _normalize_model() helper, called by both get_info and get_token_limit, strips the optional [region.]anthropic. prefix and -vN:M suffix. Native IDs and table values unchanged.

Item Before After
get_info("us.anthropic.claude-3-5-sonnet-20240620-v1:0") ❌ KeyError ✅ resolves to claude-3-5-sonnet-20240620 entry
get_token_limit("anthropic.claude-…-v1:0") ❌ 100000 fallback ✅ 200000 (table)
global./eu./apac. prefixes ❌ KeyError ✅ resolve
Native IDs (claude-3-5-sonnet-20240620, claude-opus-4-0) ✅ ✅ unchanged
Public API / function signatures — unchanged
_MODEL_INFO / _MODEL_TOKEN_LIMITS table values — unchanged (out of scope)

Tests

Added a parametrized no-network test; reverting the source (test kept) → 5 failures with the KeyError above; restored → 5 pass; full no-network anthropic suite 23 passed. ruff format/check clean, pyright 0 errors.

Out of scope / follow-up: correcting individual table values (context windows etc.) is a separate data concern, intentionally left out to keep this minimal.


This contribution was prepared with the help of an AI agent (Claude Code); a human reviewed the change, rationale, and test results before submission.

…fo lookup

The Anthropic model-info matcher in _model_info.py is prefix-anchored
(model.startswith(...)), so AWS Bedrock model IDs and cross-region
inference profiles (anthropic.*, us./eu./apac./global.anthropic.*, with
a -vN:M suffix) never resolve. get_info() then raises KeyError and
get_token_limit() silently returns the 100000 fallback instead of the
table value.

Add a small _normalize_model() helper, shared by get_info() and
get_token_limit(), that strips the optional region/provider prefix and
the Bedrock version suffix so these IDs resolve to the existing table
entries the same way the native IDs do. Native IDs are unchanged. Table
values are out of scope.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kimnamu

Copy link
Copy Markdown
Author

Thank you to the AutoGen maintainers for the years of work on this project and its Anthropic and Bedrock model clients, and for stating the archived status clearly in #8366.

With the README now saying Microsoft is not providing bug fixes for AutoGen, I'm closing this PR as I offered in #7833. The lookup gap is still on main, so #7833 stays open as the record, and the branch stays on my fork for anyone who needs the patch.

main @ d07c667a
us.anthropic.claude-3-5-sonnet-20240620-v1:0   get_info: KeyError get_token_limit: 100000
claude-3-5-sonnet-20240620                     get_info: ok       get_token_limit: 200000
How this was run

_model_info.py was loaded from main @ d07c667 and from this branch (6722aab), and get_info / get_token_limit were called directly. On this branch both IDs resolve to the same entry with 200000. The other four Bedrock forms in this PR's test (anthropic., eu., apac., global.) give the same KeyError / 100000 on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant