From 4f7039b85bb3bff7882d9bab598274418794386a Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Wed, 25 Nov 2026 12:38:52 -0800 Subject: [PATCH] fix(py): refresh the Claude catalog to the models the Claude API serves Add Fable 5.2, Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.1 and Opus 5. Drop Sonnet 4, Opus 4 and Opus 4.1, which Anthropic has retired; they still resolve on demand with generic capabilities. --- .../src/genkit_anthropic/_model_info.py | 237 +++++------------- .../tests/anthropic_plugin_test.py | 32 ++- 2 files changed, 87 insertions(+), 182 deletions(-) diff --git a/packages/genkit-anthropic/src/genkit_anthropic/_model_info.py b/packages/genkit-anthropic/src/genkit_anthropic/_model_info.py index f370ad4e8..eb72d4f20 100644 --- a/packages/genkit-anthropic/src/genkit_anthropic/_model_info.py +++ b/packages/genkit-anthropic/src/genkit_anthropic/_model_info.py @@ -20,195 +20,92 @@ from genkit.model import ConstrainedSupport, ModelInfo, ModelSupports -# Model definitions -CLAUDE_SONNET_4 = ModelInfo( - label='Anthropic - Claude Sonnet 4', - versions=['claude-sonnet-4-20250514'], - supports=ModelSupports( - multiturn=True, - media=True, - tools=True, - system_role=True, - ), -) - -CLAUDE_OPUS_4 = ModelInfo( - label='Anthropic - Claude Opus 4', - versions=['claude-opus-4-20250514'], - supports=ModelSupports( - multiturn=True, - media=True, - tools=True, - system_role=True, - ), -) - -CLAUDE_SONNET_4_5 = ModelInfo( - label='Anthropic - Claude Sonnet 4.5', - versions=['claude-sonnet-4-5-20250929'], - supports=ModelSupports( - multiturn=True, - media=True, - tools=True, - system_role=True, - output=['text', 'json'], - constrained=ConstrainedSupport.ALL, - ), -) - -CLAUDE_SONNET_4_6 = ModelInfo( - label='Anthropic - Claude Sonnet 4.6', - versions=['claude-sonnet-4-6'], - supports=ModelSupports( - multiturn=True, - media=True, - tools=True, - system_role=True, - output=['text', 'json'], - constrained=ConstrainedSupport.ALL, - ), -) - -CLAUDE_SONNET_5 = ModelInfo( - label='Anthropic - Claude Sonnet 5', - versions=['claude-sonnet-5'], - supports=ModelSupports( - multiturn=True, - media=True, - tools=True, - system_role=True, - output=['text', 'json'], - constrained=ConstrainedSupport.ALL, - ), -) - -CLAUDE_HAIKU_4_5 = ModelInfo( - label='Anthropic - Claude Haiku 4.5', - versions=['claude-haiku-4-5-20251001'], - supports=ModelSupports( - multiturn=True, - media=True, - tools=True, - system_role=True, - output=['text', 'json'], - constrained=ConstrainedSupport.ALL, - ), -) +# Source: https://platform.claude.com/docs/en/models/overview and +# https://platform.claude.com/docs/en/about-claude/model-deprecations +# (checked 2026-11-25). The catalog holds every model the Claude API serves +# today, active or deprecated; retired models are dropped. Any other id still +# resolves on demand, with DEFAULT_SUPPORTS. -CLAUDE_OPUS_4_1 = ModelInfo( - label='Anthropic - Claude Opus 4.1', - versions=['claude-opus-4-1-20250805'], - supports=ModelSupports( - multiturn=True, - media=True, - tools=True, - system_role=True, - output=['text', 'json'], - constrained=ConstrainedSupport.ALL, - ), -) -CLAUDE_OPUS_4_5 = ModelInfo( - label='Anthropic - Claude Opus 4.5', - versions=['claude-opus-4-5-20251101'], - supports=ModelSupports( - multiturn=True, - media=True, - tools=True, - system_role=True, - output=['text', 'json'], - constrained=ConstrainedSupport.ALL, - ), -) +def _claude(label: str, version: str) -> ModelInfo: + """A cataloged Claude: text, images, tools, and native structured output. -# Source: https://docs.anthropic.com/en/docs/about-claude/models -# Released: February 5, 2026. Most capable model — excels in coding, agents, -# and enterprise workflows. Supports 1M context window (beta). -CLAUDE_OPUS_4_6 = ModelInfo( - label='Anthropic - Claude Opus 4.6', - versions=['claude-opus-4-6'], - supports=ModelSupports( - multiturn=True, - media=True, - tools=True, - system_role=True, - output=['text', 'json'], - constrained=ConstrainedSupport.ALL, - ), -) + ``version`` is the id sent to the API. From the 4.6 generation on, the + dateless id is itself a pinned snapshot; older models send the dated id. + """ + return ModelInfo( + label=f'Anthropic - {label}', + versions=[version], + supports=ModelSupports( + multiturn=True, + media=True, + tools=True, + system_role=True, + output=['text', 'json'], + constrained=ConstrainedSupport.ALL, + ), + ) -CLAUDE_OPUS_4_7 = ModelInfo( - label='Anthropic - Claude Opus 4.7', - versions=['claude-opus-4-7'], - supports=ModelSupports( - multiturn=True, - media=True, - tools=True, - system_role=True, - output=['text', 'json'], - constrained=ConstrainedSupport.ALL, - ), -) -CLAUDE_OPUS_4_8 = ModelInfo( - label='Anthropic - Claude Opus 4.8', - versions=['claude-opus-4-8'], - supports=ModelSupports( - multiturn=True, - media=True, - tools=True, - system_role=True, - output=['text', 'json'], - constrained=ConstrainedSupport.ALL, - ), -) +# Latest models. +CLAUDE_FABLE_5_2 = _claude('Claude Fable 5.2', 'claude-fable-5-2') +CLAUDE_OPUS_5_5 = _claude('Claude Opus 5.5', 'claude-opus-5-5') +CLAUDE_SONNET_5_5 = _claude('Claude Sonnet 5.5', 'claude-sonnet-5-5') +CLAUDE_HAIKU_5_5 = _claude('Claude Haiku 5.5', 'claude-haiku-5-5') +# Earlier models, still served. +CLAUDE_FABLE_5_1 = _claude('Claude Fable 5.1', 'claude-fable-5-1') +CLAUDE_FABLE_5 = _claude('Claude Fable 5', 'claude-fable-5') +CLAUDE_OPUS_5 = _claude('Claude Opus 5', 'claude-opus-5') +CLAUDE_OPUS_4_8 = _claude('Claude Opus 4.8', 'claude-opus-4-8') +CLAUDE_OPUS_4_7 = _claude('Claude Opus 4.7', 'claude-opus-4-7') +CLAUDE_OPUS_4_6 = _claude('Claude Opus 4.6', 'claude-opus-4-6') +CLAUDE_SONNET_5 = _claude('Claude Sonnet 5', 'claude-sonnet-5') +CLAUDE_SONNET_4_6 = _claude('Claude Sonnet 4.6', 'claude-sonnet-4-6') +CLAUDE_HAIKU_4_5 = _claude('Claude Haiku 4.5', 'claude-haiku-4-5-20251001') -CLAUDE_FABLE_5 = ModelInfo( - label='Anthropic - Claude Fable 5', - versions=['claude-fable-5'], - supports=ModelSupports( - multiturn=True, - media=True, - tools=True, - system_role=True, - output=['text', 'json'], - constrained=ConstrainedSupport.ALL, - ), -) +# Deprecated: Opus 4.5 retires 2027-01-22, Sonnet 4.5 retires 2026-11-30. +CLAUDE_OPUS_4_5 = _claude('Claude Opus 4.5', 'claude-opus-4-5-20251101') +CLAUDE_SONNET_4_5 = _claude('Claude Sonnet 4.5', 'claude-sonnet-4-5-20250929') # Quote autocomplete needs a Literal. The catalog below is what you edit when -# a Claude ships; a test requires these members and the dict keys to be the -# same set, and the dict is typed so a new key that is not in the Literal -# does not type-check. +# a Claude ships or retires; a test requires these members and the dict keys +# to be the same set, and the dict is typed so a new key that is not in the +# Literal does not type-check. KnownClaude: TypeAlias = Literal[ - 'claude-sonnet-4', - 'claude-opus-4', - 'claude-sonnet-4-5', - 'claude-sonnet-4-6', + 'claude-fable-5-2', + 'claude-opus-5-5', + 'claude-sonnet-5-5', + 'claude-haiku-5-5', + 'claude-fable-5-1', + 'claude-fable-5', + 'claude-opus-5', + 'claude-opus-4-8', + 'claude-opus-4-7', + 'claude-opus-4-6', 'claude-sonnet-5', + 'claude-sonnet-4-6', 'claude-haiku-4-5', - 'claude-opus-4-1', 'claude-opus-4-5', - 'claude-opus-4-6', - 'claude-opus-4-7', - 'claude-opus-4-8', - 'claude-fable-5', + 'claude-sonnet-4-5', ] SUPPORTED_ANTHROPIC_MODELS: dict[KnownClaude, ModelInfo] = { - 'claude-sonnet-4': CLAUDE_SONNET_4, - 'claude-opus-4': CLAUDE_OPUS_4, - 'claude-sonnet-4-5': CLAUDE_SONNET_4_5, - 'claude-sonnet-4-6': CLAUDE_SONNET_4_6, + 'claude-fable-5-2': CLAUDE_FABLE_5_2, + 'claude-opus-5-5': CLAUDE_OPUS_5_5, + 'claude-sonnet-5-5': CLAUDE_SONNET_5_5, + 'claude-haiku-5-5': CLAUDE_HAIKU_5_5, + 'claude-fable-5-1': CLAUDE_FABLE_5_1, + 'claude-fable-5': CLAUDE_FABLE_5, + 'claude-opus-5': CLAUDE_OPUS_5, + 'claude-opus-4-8': CLAUDE_OPUS_4_8, + 'claude-opus-4-7': CLAUDE_OPUS_4_7, + 'claude-opus-4-6': CLAUDE_OPUS_4_6, 'claude-sonnet-5': CLAUDE_SONNET_5, + 'claude-sonnet-4-6': CLAUDE_SONNET_4_6, 'claude-haiku-4-5': CLAUDE_HAIKU_4_5, - 'claude-opus-4-1': CLAUDE_OPUS_4_1, 'claude-opus-4-5': CLAUDE_OPUS_4_5, - 'claude-opus-4-6': CLAUDE_OPUS_4_6, - 'claude-opus-4-7': CLAUDE_OPUS_4_7, - 'claude-opus-4-8': CLAUDE_OPUS_4_8, - 'claude-fable-5': CLAUDE_FABLE_5, + 'claude-sonnet-4-5': CLAUDE_SONNET_4_5, } DEFAULT_SUPPORTS = ModelSupports( diff --git a/packages/genkit-anthropic/tests/anthropic_plugin_test.py b/packages/genkit-anthropic/tests/anthropic_plugin_test.py index db5f9cc6c..ec33b056d 100644 --- a/packages/genkit-anthropic/tests/anthropic_plugin_test.py +++ b/packages/genkit-anthropic/tests/anthropic_plugin_test.py @@ -165,8 +165,10 @@ async def _get_client() -> object: def test_supported_models() -> None: """Test that all supported models have proper metadata.""" - assert len(SUPPORTED_MODELS) == 12 - assert 'claude-3-haiku' not in SUPPORTED_MODELS + assert len(SUPPORTED_MODELS) == 15 + # Retired on the Claude API, so not advertised; they still resolve on demand. + for retired in ('claude-3-haiku', 'claude-sonnet-4', 'claude-opus-4', 'claude-opus-4-1'): + assert retired not in SUPPORTED_MODELS for _name, info in SUPPORTED_MODELS.items(): assert info.label is not None assert info.label.startswith('Anthropic - ') @@ -179,6 +181,12 @@ def test_supported_models() -> None: assert info.supports.system_role is True for model_name, expected_label in ( + ('claude-fable-5-2', 'Anthropic - Claude Fable 5.2'), + ('claude-opus-5-5', 'Anthropic - Claude Opus 5.5'), + ('claude-sonnet-5-5', 'Anthropic - Claude Sonnet 5.5'), + ('claude-haiku-5-5', 'Anthropic - Claude Haiku 5.5'), + ('claude-fable-5-1', 'Anthropic - Claude Fable 5.1'), + ('claude-opus-5', 'Anthropic - Claude Opus 5'), ('claude-opus-4-7', 'Anthropic - Claude Opus 4.7'), ('claude-opus-4-8', 'Anthropic - Claude Opus 4.8'), ('claude-sonnet-4-6', 'Anthropic - Claude Sonnet 4.6'), @@ -204,8 +212,8 @@ def test_mythos_excluded_but_resolvable() -> None: def test_get_model_info_known() -> None: """Test get_model_info returns correct info for known model.""" - info = get_model_info('claude-sonnet-4') - assert info.label == 'Anthropic - Claude Sonnet 4' + info = get_model_info('claude-sonnet-5-5') + assert info.label == 'Anthropic - Claude Sonnet 5.5' assert info.supports is not None assert info.supports.multiturn is True assert info.supports.tools is True @@ -250,7 +258,7 @@ async def test_list_actions_dynamic_union_dedup_and_fallback_info() -> None: mock_client = MagicMock() api_items = [ SimpleNamespace(id='claude-mythos-5'), # unknown id -> generic fallback info - SimpleNamespace(id='claude-sonnet-4'), # known static id -> must appear once, curated info + SimpleNamespace(id='claude-sonnet-5-5'), # known static id -> must appear once, curated info SimpleNamespace(id='claude-unknown-xyz'), # unknown id -> generic fallback info ] mock_client.beta.models.list = MagicMock(return_value=_FakeModelPage(api_items)) @@ -264,20 +272,20 @@ async def test_list_actions_dynamic_union_dedup_and_fallback_info() -> None: # API ids present, in API order, first. assert names[0] == 'anthropic/claude-mythos-5' - assert names[1] == 'anthropic/claude-sonnet-4' + assert names[1] == 'anthropic/claude-sonnet-5-5' assert names[2] == 'anthropic/claude-unknown-xyz' # Static-only ids the mock didn't return are still present (appended after API ids). for model_id in SUPPORTED_MODELS: - if model_id != 'claude-sonnet-4': + if model_id != 'claude-sonnet-5-5': assert anthropic_name(model_id) in names assert len(names) == 3 + len(SUPPORTED_MODELS) - 1 # Curated info preserved for a known id returned by the API. - sonnet_action = next(a for a in actions if a.name == 'anthropic/claude-sonnet-4') + sonnet_action = next(a for a in actions if a.name == 'anthropic/claude-sonnet-5-5') assert sonnet_action.metadata is not None sonnet_model = cast(dict[str, Any], sonnet_action.metadata['model']) - assert sonnet_model['label'] == 'Anthropic - Claude Sonnet 4' + assert sonnet_model['label'] == 'Anthropic - Claude Sonnet 5.5' # Unknown ids get the generic fallback info, not curated. mythos_action = next(a for a in actions if a.name == 'anthropic/claude-mythos-5') @@ -308,7 +316,7 @@ async def test_list_actions_caches_on_success() -> None: """A successful API fetch is memoized for the plugin's lifetime.""" plugin = Anthropic(api_key='test-key') mock_client = MagicMock() - mock_client.beta.models.list = MagicMock(return_value=_FakeModelPage([SimpleNamespace(id='claude-sonnet-4')])) + mock_client.beta.models.list = MagicMock(return_value=_FakeModelPage([SimpleNamespace(id='claude-sonnet-5-5')])) plugin._runtime_client = lambda: mock_client first = await plugin.list_actions() @@ -323,7 +331,7 @@ async def test_list_actions_skips_empty_model_ids() -> None: plugin = Anthropic(api_key='test-key') mock_client = MagicMock() api_items = [ - SimpleNamespace(id='claude-sonnet-4'), + SimpleNamespace(id='claude-sonnet-5-5'), SimpleNamespace(id=''), # empty id -> dropped SimpleNamespace(id=None), # missing id -> dropped ] @@ -334,7 +342,7 @@ async def test_list_actions_skips_empty_model_ids() -> None: names = [a.name for a in actions] # The valid id is present; the empty/missing ones produce no action. - assert 'anthropic/claude-sonnet-4' in names + assert 'anthropic/claude-sonnet-5-5' in names assert 'anthropic/' not in names assert 'anthropic/None' not in names # Only the static set is advertised (the one API id overlaps it).