From 8d2a55beb3af163a4e8165ac467e3447582fae28 Mon Sep 17 00:00:00 2001 From: Ayham Joumran <140757050+AyhamJo7@users.noreply.github.com> Date: Mon, 23 Nov 2026 00:38:51 +0100 Subject: [PATCH] fix(anthropic): default to a Claude model Anthropic still serves AnthropicProvider.DEFAULT_MODEL, the refusal classifier's AnthropicClient and create_llm_classifier(provider='anthropic') all defaulted to claude-3-haiku-20240307, which Anthropic retired on 2026-04-20, so every Anthropic call without a model failed. They now use claude-haiku-5-5, the current Haiku. The two snapshot tests that pinned the old default now pin the new one, and a classifier test covers its factory default. --- agentic_security/llm_providers/anthropic_provider.py | 2 +- agentic_security/refusal_classifier/llm_classifier.py | 4 ++-- tests/unit/llm_providers/test_anthropic_provider.py | 2 +- tests/unit/llm_providers/test_factory.py | 2 +- tests/unit/refusal_classifier/test_llm_classifier.py | 6 ++++++ 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/agentic_security/llm_providers/anthropic_provider.py b/agentic_security/llm_providers/anthropic_provider.py index c63b0d5..14e1a48 100644 --- a/agentic_security/llm_providers/anthropic_provider.py +++ b/agentic_security/llm_providers/anthropic_provider.py @@ -15,7 +15,7 @@ from agentic_security.llm_providers.base import ( class AnthropicProvider(BaseLLMProvider): """Anthropic API provider supporting messages API.""" - DEFAULT_MODEL = "claude-3-haiku-20240307" + DEFAULT_MODEL = "claude-haiku-5-5" API_KEY_ENV = "ANTHROPIC_API_KEY" def __init__( diff --git a/agentic_security/refusal_classifier/llm_classifier.py b/agentic_security/refusal_classifier/llm_classifier.py index 6800302..d34bffa 100644 --- a/agentic_security/refusal_classifier/llm_classifier.py +++ b/agentic_security/refusal_classifier/llm_classifier.py @@ -94,7 +94,7 @@ class AnthropicClient: """Anthropic API client.""" api_key: str | None = None - model: str = "claude-3-haiku-20240307" + model: str = "claude-haiku-5-5" def __post_init__(self): self.api_key = self.api_key or os.environ.get("ANTHROPIC_API_KEY") @@ -211,7 +211,7 @@ def create_llm_classifier( elif provider == "anthropic": client = AnthropicClient( api_key=api_key, - model=model or "claude-3-haiku-20240307", + model=model or "claude-haiku-5-5", ) else: raise ValueError(f"Unknown provider: {provider}") diff --git a/tests/unit/llm_providers/test_anthropic_provider.py b/tests/unit/llm_providers/test_anthropic_provider.py index ac990f9..6a5c647 100644 --- a/tests/unit/llm_providers/test_anthropic_provider.py +++ b/tests/unit/llm_providers/test_anthropic_provider.py @@ -32,7 +32,7 @@ class TestAnthropicProviderInit: def test_default_model(self, monkeypatch): monkeypatch.setenv("ANTHROPIC_API_KEY", "test-key") provider = AnthropicProvider() - assert provider.model == snapshot("claude-3-haiku-20240307") + assert provider.model == snapshot("claude-haiku-5-5") def test_custom_model(self, monkeypatch): monkeypatch.setenv("ANTHROPIC_API_KEY", "test-key") diff --git a/tests/unit/llm_providers/test_factory.py b/tests/unit/llm_providers/test_factory.py index ff00b9e..1b58fcb 100644 --- a/tests/unit/llm_providers/test_factory.py +++ b/tests/unit/llm_providers/test_factory.py @@ -91,7 +91,7 @@ class TestCreateProvider: def test_create_anthropic_with_default_model(self, monkeypatch): monkeypatch.setenv("ANTHROPIC_API_KEY", "test-key") provider = create_provider("anthropic") - assert provider.model == snapshot("claude-3-haiku-20240307") + assert provider.model == snapshot("claude-haiku-5-5") def test_create_anthropic_with_custom_model(self, monkeypatch): monkeypatch.setenv("ANTHROPIC_API_KEY", "test-key") diff --git a/tests/unit/refusal_classifier/test_llm_classifier.py b/tests/unit/refusal_classifier/test_llm_classifier.py index 502ae58..6a2aab7 100644 --- a/tests/unit/refusal_classifier/test_llm_classifier.py +++ b/tests/unit/refusal_classifier/test_llm_classifier.py @@ -154,6 +154,12 @@ class TestCreateLLMClassifier: with pytest.raises(ValueError, match="Anthropic API key required"): create_llm_classifier(provider="anthropic") + def test_create_anthropic_default_model(self, monkeypatch): + # claude-3-haiku-20240307 was retired by Anthropic on 2026-04-20. + monkeypatch.setenv("ANTHROPIC_API_KEY", "test-key") + classifier = create_llm_classifier(provider="anthropic") + assert classifier.client.model == snapshot("claude-haiku-5-5") + def test_create_unknown_provider(self): with pytest.raises(ValueError, match="Unknown provider"): create_llm_classifier(provider="unknown")