2026-04-25 09:37:14 -07:00
|
|
|
"""Smoke tests for the multi-provider setup."""
|
2026-04-24 23:43:56 -07:00
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
from agents.exceptions import UserError
|
|
|
|
|
|
|
|
|
|
from strix.llm.anthropic_cache_wrapper import AnthropicCachingLitellmModel
|
|
|
|
|
from strix.llm.multi_provider_setup import (
|
2026-04-25 09:37:14 -07:00
|
|
|
_AnthropicCachingProvider,
|
2026-04-24 23:43:56 -07:00
|
|
|
build_multi_provider,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2026-04-25 09:37:14 -07:00
|
|
|
def test_anthropic_provider_wraps_in_caching_model() -> None:
|
|
|
|
|
provider = _AnthropicCachingProvider()
|
|
|
|
|
model = provider.get_model("claude-sonnet-4-6")
|
2026-04-24 23:43:56 -07:00
|
|
|
assert isinstance(model, AnthropicCachingLitellmModel)
|
2026-04-25 09:37:14 -07:00
|
|
|
# The provider re-prefixes with ``anthropic/`` so litellm routes correctly.
|
|
|
|
|
assert model.model == "anthropic/claude-sonnet-4-6"
|
2026-04-24 23:43:56 -07:00
|
|
|
assert model._is_anthropic() is True
|
|
|
|
|
|
|
|
|
|
|
2026-04-25 09:37:14 -07:00
|
|
|
def test_anthropic_provider_preserves_existing_anthropic_prefix() -> None:
|
|
|
|
|
"""If the alias already carries ``anthropic/``, don't double-prefix."""
|
|
|
|
|
provider = _AnthropicCachingProvider()
|
|
|
|
|
model = provider.get_model("anthropic/claude-3-5-sonnet-20241022")
|
|
|
|
|
assert model.model == "anthropic/claude-3-5-sonnet-20241022"
|
2026-04-24 23:43:56 -07:00
|
|
|
|
|
|
|
|
|
2026-04-25 09:37:14 -07:00
|
|
|
def test_anthropic_provider_empty_name_raises() -> None:
|
|
|
|
|
provider = _AnthropicCachingProvider()
|
2026-04-24 23:43:56 -07:00
|
|
|
with pytest.raises(UserError, match="non-empty"):
|
|
|
|
|
provider.get_model(None)
|
|
|
|
|
|
|
|
|
|
|
2026-04-25 09:37:14 -07:00
|
|
|
def test_build_multi_provider_routes_anthropic_through_caching_wrapper() -> None:
|
|
|
|
|
"""The configured MultiProvider should hit our caching wrapper for the
|
|
|
|
|
``anthropic/`` prefix."""
|
2026-04-24 23:43:56 -07:00
|
|
|
mp = build_multi_provider()
|
2026-04-25 09:37:14 -07:00
|
|
|
model = mp.get_model("anthropic/claude-sonnet-4-6")
|
2026-04-24 23:43:56 -07:00
|
|
|
assert isinstance(model, AnthropicCachingLitellmModel)
|