Merge pull request #391 from AyhamJo7/fix/anthropic-default-model

fix(anthropic): default to a Claude model Anthropic still serves
This commit is contained in:
Alexander Myasoedov authored and GitHub committed 2026-11-23 13:29:39 +02:00
commit 70fc9267d9
5 files changed
+11 -5

No files matched your search

@@ -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__(
@@ -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}")
@@ -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")
+1 -1
View File
@@ -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")
@@ -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")