mirror of
https://github.com/usestrix/strix.git
synced 2026-08-20 10:33:34 +02:00
fix(llm): resolve grok/ models to xai/ for LiteLLM metadata
LiteLLM maps xAI models only provider-qualified, so neither "grok/grok-4" nor bare "grok-4" resolves: subscription runs fell back to the generic 200k context window and an 8k output cap instead of Grok's 256k/256k. subscription.litellm_model_name() now owns the routing-prefix -> LiteLLM name mapping (grok/ -> xai/, chatgpt/ -> bare) and context_budget uses it.
This commit is contained in:
@@ -39,6 +39,17 @@ def test_context_window_chatgpt_prefix_skips_provider_auth(
|
||||
context_budget._model_info.cache_clear()
|
||||
|
||||
|
||||
def test_context_window_grok_prefix_resolves_to_xai() -> None:
|
||||
# LiteLLM maps xAI models only provider-qualified: neither "grok/grok-4" nor
|
||||
# bare "grok-4" resolves, so the subscription prefix becomes "xai/".
|
||||
context_budget._model_info.cache_clear()
|
||||
try:
|
||||
assert context_budget.context_window("grok/grok-4") == 256_000
|
||||
assert context_budget.output_limit("grok/grok-4") == 256_000
|
||||
finally:
|
||||
context_budget._model_info.cache_clear()
|
||||
|
||||
|
||||
def test_context_window_unmapped_uses_fallback(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
context_budget._model_info.cache_clear()
|
||||
|
||||
|
||||
@@ -47,6 +47,17 @@ def test_provider_label_names_the_subscription() -> None:
|
||||
assert subscription.provider_label("openai/gpt-5.4") is None
|
||||
|
||||
|
||||
def test_litellm_model_name_maps_subscription_prefixes() -> None:
|
||||
# Model metadata (context window, output cap) is keyed "xai/…" for Grok and
|
||||
# bare for ChatGPT; the routing prefixes themselves are never LiteLLM keys.
|
||||
assert subscription.litellm_model_name("grok/grok-4") == "xai/grok-4"
|
||||
assert subscription.litellm_model_name("chatgpt/gpt-5.4") == "gpt-5.4"
|
||||
# Non-subscription models pass through untouched.
|
||||
assert subscription.litellm_model_name("xai/grok-4") == "xai/grok-4"
|
||||
assert subscription.litellm_model_name("openai/gpt-5.4") == "openai/gpt-5.4"
|
||||
assert subscription.litellm_model_name(None) is None
|
||||
|
||||
|
||||
def test_run_record_reports_grok_provider(monkeypatch) -> None: # type: ignore[no-untyped-def]
|
||||
settings = mock.MagicMock()
|
||||
settings.llm.model = "grok/grok-4"
|
||||
|
||||
Reference in New Issue
Block a user