refactor: remove all strix/ model alias machinery

The Strix proxy / ``strix/`` model namespace is gone. Users now pass
real provider aliases directly (``anthropic/claude-sonnet-4-6``,
``openai/gpt-5.4``, ``gemini/...``, ``openrouter/...``).

Deleted:
- ``STRIX_API_BASE`` constant in ``strix/config/config.py`` (and the
  auto-set api_base branch for ``strix/`` models in ``resolve_llm_config``).
- ``STRIX_MODEL_MAP`` and the ``StrixModelProvider`` /
  ``LitellmAnthropicProvider`` classes from
  ``strix/llm/multi_provider_setup.py``.
- ``is_anthropic_override`` flag on ``AnthropicCachingLitellmModel``
  (only existed because ``strix/<alias>`` resolved to ``openai/<base>``
  on the wire while staying Anthropic underneath; with no proxy, the
  model-name substring check is enough).
- ``startswith("strix/")`` branches in ``cli.py`` / ``main.py`` /
  ``dedupe.py`` and the ``uses_strix_models`` env-validation flag.

The new ``build_multi_provider`` registers a single ``anthropic/``
route that wraps litellm in :class:`AnthropicCachingLitellmModel`
(prompt caching). Every other prefix falls through to the SDK's
built-in routing.

Defaults flipped from ``strix/claude-sonnet-4.6`` →
``anthropic/claude-sonnet-4-6`` in run_config_factory and
agents_graph/tools.py + corresponding tests.

Tests updated:
- ``test_anthropic_cache_wrapper.py``: drop the override-flag tests.
- ``test_multi_provider_setup.py``: rewrite around the new single
  ``_AnthropicCachingProvider`` route.
- ``test_tool_registration_modes.py::test_load_skill_import_...``:
  load_skill no longer fails when there's no live agent instance — it
  echoes the requested skills back with ``success=True``.

Tests: 281/281 passing.
This commit is contained in:
0xallam
2026-04-25 09:37:14 -07:00
parent 5606504563
commit fec2934378
13 changed files with 69 additions and 223 deletions
+2 -2
View File
@@ -184,8 +184,8 @@ def build_strix_agent(
instructions=instructions,
tools=tools,
tool_use_behavior=StopAtTools(stop_at_tool_names=list(stop_at)),
# model=None so ``RunConfig.model`` (e.g. ``strix/claude-sonnet-4.6``)
# routes through MultiProvider rather than the SDK's default.
# model=None so ``RunConfig.model`` drives provider selection
# via :func:`build_multi_provider` rather than the SDK's default.
model=None,
)
+11 -19
View File
@@ -5,9 +5,6 @@ from pathlib import Path
from typing import Any, ClassVar
STRIX_API_BASE = "https://models.strix.ai/api/v1"
class Config:
"""Configuration Manager for Strix."""
@@ -197,28 +194,23 @@ def save_current_config() -> bool:
def resolve_llm_config() -> tuple[str | None, str | None, str | None]:
"""Resolve LLM model, api_key, and api_base based on STRIX_LLM prefix.
"""Resolve LLM model, api_key, and api_base.
Returns:
tuple: (model_name, api_key, api_base)
- model_name: Original model name (strix/ prefix preserved for display)
- api_key: LLM API key
- api_base: API base URL (auto-set to STRIX_API_BASE for strix/ models)
Returns ``(model_name, api_key, api_base)``. ``api_base`` falls back
through the ``LLM_API_BASE`` / ``OPENAI_API_BASE`` /
``LITELLM_BASE_URL`` / ``OLLAMA_API_BASE`` env chain so the user can
point at any OpenAI-compatible endpoint without changing the code.
"""
model = Config.get("strix_llm")
if not model:
return None, None, None
api_key = Config.get("llm_api_key")
if model.startswith("strix/"):
api_base: str | None = STRIX_API_BASE
else:
api_base = (
Config.get("llm_api_base")
or Config.get("openai_api_base")
or Config.get("litellm_base_url")
or Config.get("ollama_api_base")
)
api_base: str | None = (
Config.get("llm_api_base")
or Config.get("openai_api_base")
or Config.get("litellm_base_url")
or Config.get("ollama_api_base")
)
return model, api_key, api_base
+1 -10
View File
@@ -20,7 +20,6 @@ from rich.text import Text
from strix.config import Config, apply_saved_config, save_current_config
from strix.config.config import resolve_llm_config
from strix.llm.multi_provider_setup import STRIX_MODEL_MAP
apply_saved_config()
@@ -58,12 +57,10 @@ def validate_environment() -> None:
missing_optional_vars = []
strix_llm = Config.get("strix_llm")
uses_strix_models = strix_llm and strix_llm.startswith("strix/")
if not strix_llm:
missing_required_vars.append("STRIX_LLM")
has_base_url = uses_strix_models or any(
has_base_url = any(
[
Config.get("llm_api_base"),
Config.get("openai_api_base"),
@@ -211,13 +208,7 @@ async def warm_up_llm() -> None:
try:
model_name, api_key, api_base = resolve_llm_config()
# ``strix/<alias>`` is routed through the Strix proxy (OpenAI-compatible);
# everything else is sent as-is.
litellm_model: str | None = model_name
if model_name and model_name.startswith("strix/"):
base = model_name[len("strix/") :]
if base in STRIX_MODEL_MAP:
litellm_model = f"openai/{base}"
test_messages = [
{"role": "system", "content": "You are a helpful assistant."},
-19
View File
@@ -30,28 +30,9 @@ class AnthropicCachingLitellmModel(LitellmModel):
Detection: case-insensitive substring match on ``"anthropic/"`` or
``"claude"`` against the model name.
For Strix proxy routing where the API model is ``openai/<base>`` but the
underlying provider is still Anthropic (e.g., ``strix/claude-sonnet-4.6``
resolves to api_model=``openai/claude-sonnet-4.6`` against the Strix
proxy with a canonical of ``anthropic/claude-sonnet-4-6``), pass
``is_anthropic_override=True`` so the wrapper still injects cache_control
even though the model name doesn't match the heuristic.
"""
def __init__(
self,
model: str,
*,
is_anthropic_override: bool | None = None,
**kwargs: Any,
) -> None:
super().__init__(model=model, **kwargs)
self._is_anthropic_override = is_anthropic_override
def _is_anthropic(self) -> bool:
if self._is_anthropic_override is not None:
return self._is_anthropic_override
m = (self.model or "").lower()
return "anthropic/" in m or "claude" in m
-5
View File
@@ -6,7 +6,6 @@ from typing import Any
import litellm
from strix.config.config import resolve_llm_config
from strix.llm.multi_provider_setup import STRIX_MODEL_MAP
logger = logging.getLogger(__name__)
@@ -158,10 +157,6 @@ def check_duplicate(
model_name, api_key, api_base = resolve_llm_config()
litellm_model: str | None = model_name
if model_name and model_name.startswith("strix/"):
base = model_name[len("strix/") :]
if base in STRIX_MODEL_MAP:
litellm_model = f"openai/{base}"
messages = [
{"role": "system", "content": DEDUPE_SYSTEM_PROMPT},
+22 -86
View File
@@ -1,116 +1,52 @@
"""Multi-provider routing setup for Strix on top of the SDK MultiProvider.
"""Multi-provider routing setup.
The SDK's ``MultiProvider`` resolves a model name like ``"strix/claude-sonnet-4.6"``
by stripping the prefix (``"strix"``) and dispatching to a registered
``ModelProvider`` keyed on that prefix. We register two custom providers:
- ``"strix"`` ``StrixModelProvider``: aliases the short name to a Strix-proxy
``openai/<base>`` model URL, but knows whether the underlying provider is
Anthropic so cache-control still gets injected at the message layer.
- ``"litellm/anthropic"`` → ``LitellmAnthropicProvider``: direct Anthropic
routing via LiteLLM, always Anthropic, always caching.
Other prefixes fall through to the SDK's built-in OpenAI / LiteLLM defaults.
Wraps the SDK's :class:`MultiProvider` and registers a custom Anthropic
route so models named ``anthropic/<model>`` go through
:class:`AnthropicCachingLitellmModel` (which injects ``cache_control``
on the system message). Every other prefix
(``openai/`` / ``gemini/`` / ``openrouter/`` / ``litellm/...``) falls
through to the SDK's built-in litellm routing.
References:
- PLAYBOOK.md §2.7
- AUDIT_R3.md C17 (model alias validation; raise UserError on unknown alias)
- AUDIT_R3.md C17 (model alias validation; raise UserError on bad alias)
"""
from __future__ import annotations
from agents.exceptions import UserError
from agents.extensions.models.litellm_model import LitellmModel
from agents.models.interface import Model, ModelProvider
from agents.models.multi_provider import MultiProvider, MultiProviderMap
from strix.config.config import STRIX_API_BASE
from strix.llm.anthropic_cache_wrapper import AnthropicCachingLitellmModel
# Strix-proxy aliases. Each maps the user-facing alias (right of
# ``strix/``) to the canonical provider/model used for capability
# lookups (litellm reads e.g. ``anthropic/claude-sonnet-4-6`` to
# decide on prompt-caching support).
STRIX_MODEL_MAP: dict[str, str] = {
"claude-sonnet-4.6": "anthropic/claude-sonnet-4-6",
"claude-opus-4.6": "anthropic/claude-opus-4-6",
"gpt-5.2": "openai/gpt-5.2",
"gpt-5.1": "openai/gpt-5.1",
"gpt-5.4": "openai/gpt-5.4",
"gemini-3-pro-preview": "gemini/gemini-3-pro-preview",
"gemini-3-flash-preview": "gemini/gemini-3-flash-preview",
"glm-5": "openrouter/z-ai/glm-5",
"glm-4.7": "openrouter/z-ai/glm-4.7",
}
class _AnthropicCachingProvider(ModelProvider):
"""Routes ``anthropic/<model>`` aliases through
:class:`AnthropicCachingLitellmModel`.
def _is_anthropic_canonical(canonical: str) -> bool:
"""Return True if ``canonical`` looks like an Anthropic provider/model."""
c = canonical.lower()
return "anthropic/" in c or "claude" in c
class StrixModelProvider(ModelProvider):
"""Resolves the ``strix/`` prefix.
The MultiProvider strips the prefix before calling ``get_model``, so we
receive ``"claude-sonnet-4.6"`` for ``"strix/claude-sonnet-4.6"``. The
``api_model`` (what we actually send over the wire) is always
``openai/<base>`` against the Strix proxy (which is OpenAI-compatible).
The ``canonical`` model name is what the upstream provider sees and is
used to decide whether to inject Anthropic prompt caching at the message
layer.
C17: unknown aliases raise ``UserError`` listing valid options instead of
failing opaquely later in the LLM call.
"""
def get_model(self, model_name: str | None) -> Model:
if not model_name:
raise UserError("StrixModelProvider requires a non-empty model name.")
if model_name not in STRIX_MODEL_MAP:
valid = ", ".join(sorted(STRIX_MODEL_MAP.keys()))
raise UserError(
f"Unknown Strix model alias 'strix/{model_name}'. Valid aliases: {valid}",
)
canonical = STRIX_MODEL_MAP[model_name]
api_model = f"openai/{model_name}"
if _is_anthropic_canonical(canonical):
return AnthropicCachingLitellmModel(
model=api_model,
base_url=STRIX_API_BASE,
is_anthropic_override=True,
)
return LitellmModel(model=api_model, base_url=STRIX_API_BASE)
class LitellmAnthropicProvider(ModelProvider):
"""Resolves the ``litellm/anthropic`` prefix.
The MultiProvider strips the matched prefix; for ``litellm/anthropic/...``
with a registered provider mapping of ``"litellm/anthropic"``, the call
arrives with ``model_name`` like ``"claude-sonnet-4-5-20250929"`` (the
suffix after the prefix). Always wraps in the caching model.
The SDK's ``MultiProvider`` strips the matched prefix before calling
``get_model``, so we receive bare ``"<model>"`` (e.g.
``"claude-sonnet-4-6"``) and re-prefix with ``anthropic/`` so litellm
routes to the Anthropic API.
"""
def get_model(self, model_name: str | None) -> Model:
if not model_name:
raise UserError(
"LitellmAnthropicProvider requires a non-empty model name.",
"Anthropic provider requires a non-empty model name (e.g. 'claude-sonnet-4-6').",
)
# Re-prefix for litellm so it routes to Anthropic.
full = f"anthropic/{model_name}"
full = model_name if model_name.startswith("anthropic/") else f"anthropic/{model_name}"
return AnthropicCachingLitellmModel(model=full)
def build_multi_provider() -> MultiProvider:
"""Build the configured MultiProvider for Strix.
"""Build the configured MultiProvider.
Registers Strix-specific prefix routes; OpenAI and other LiteLLM-prefixed
models are handled by the SDK's built-in routing.
Registers the ``anthropic/`` route through our caching wrapper so
prompt caching kicks in; everything else falls through to the SDK's
built-in routing.
"""
pmap = MultiProviderMap() # type: ignore[no-untyped-call]
pmap.add_provider("strix", StrixModelProvider())
pmap.add_provider("litellm/anthropic", LitellmAnthropicProvider())
pmap.add_provider("anthropic", _AnthropicCachingProvider())
return MultiProvider(provider_map=pmap)
+2 -2
View File
@@ -81,7 +81,7 @@ STRIX_DEFAULT_MAX_TURNS = 300
def make_run_config(
*,
sandbox_session: BaseSandboxSession | None,
model: str = "strix/claude-sonnet-4.6",
model: str = "anthropic/claude-sonnet-4-6",
parallel_tool_calls: bool = _PHASE1_PARALLEL_DEFAULT,
tool_choice: Literal["auto", "required", "none"] | None = "required",
reasoning_effort: Literal["low", "medium", "high"] | None = None,
@@ -163,7 +163,7 @@ def make_agent_context(
agent_name: str,
parent_id: str | None,
tracer: Any | None,
model: str = "strix/claude-sonnet-4.6",
model: str = "anthropic/claude-sonnet-4-6",
model_settings: ModelSettings | None = None,
max_turns: int = 300,
is_whitebox: bool = False,
+2 -2
View File
@@ -361,7 +361,7 @@ async def create_agent(
agent_name=name,
parent_id=parent_id,
tracer=inner.get("tracer"),
model=inner.get("model", "strix/claude-sonnet-4.6"),
model=inner.get("model", "anthropic/claude-sonnet-4-6"),
model_settings=inner.get("model_settings"),
max_turns=int(inner.get("max_turns", 300)),
is_whitebox=bool(inner.get("is_whitebox", False)),
@@ -373,7 +373,7 @@ async def create_agent(
child_run_config = make_run_config(
sandbox_session=inner.get("sandbox_session"),
sandbox_client=inner.get("sandbox_client"),
model=inner.get("model", "strix/claude-sonnet-4.6"),
model=inner.get("model", "anthropic/claude-sonnet-4-6"),
model_settings_override=inner.get("model_settings"),
)