test: retarget reasoning and search assertions for mirrored catalog

This commit is contained in:
Joshua Valluru 2026-10-20 22:59:40 -07:00
parent ff9d9b813b
commit b71dce4e0f
3 changed files with 37 additions and 26 deletions

View file

@ -634,4 +634,8 @@ class TestAgentCoreSearchEdgeCases:
from litellm.search.cost_calculator import search_provider_cost_per_query
monkeypatch.setattr(litellm, "model_cost", GetModelCostMap.load_local_model_cost_map())
assert search_provider_cost_per_query(model="agentcore/search", custom_llm_provider="agentcore") == (0.0, 0.0)
price_per_query = litellm.model_cost["agentcore/search"]["input_cost_per_query"]
assert price_per_query > 0
assert search_provider_cost_per_query(
model="agentcore/search", custom_llm_provider="agentcore", number_of_queries=3
) == (3 * price_per_query, 0.0)

View file

@ -1,5 +1,8 @@
import httpx
from typing import Final
import litellm
import pytest
@ -523,14 +526,14 @@ def test_openrouter_cost_tracking_streaming():
assert result2.usage.cost == 0.0001
def test_openrouter_reasoning_models_allow_reasoning_effort_param():
def test_openrouter_reasoning_models_allow_reasoning_effort_param(reasoning_model: str):
"""
OpenRouter reasoning-capable models should accept the reasoning_effort param.
"""
config = OpenrouterConfig()
supported_params = config.get_supported_openai_params(
model="openrouter/deepseek/deepseek-v3.2"
model=reasoning_model
)
assert "reasoning_effort" in supported_params
@ -550,7 +553,7 @@ def test_openrouter_non_reasoning_models_do_not_add_reasoning_effort():
assert "reasoning_effort" not in supported_params
def test_openrouter_reasoning_effort_max_maps_to_xhigh():
def test_openrouter_reasoning_effort_max_maps_to_xhigh(reasoning_model: str):
"""
OpenRouter expects 'xhigh' instead of 'max' for reasoning_effort.
"""
@ -559,14 +562,14 @@ def test_openrouter_reasoning_effort_max_maps_to_xhigh():
result = config.map_openai_params(
non_default_params={"reasoning_effort": "max"},
optional_params={},
model="openrouter/deepseek/deepseek-r1",
model=reasoning_model,
drop_params=False,
)
assert result["reasoning_effort"] == "xhigh"
def test_openrouter_reasoning_effort_max_does_not_mutate_caller_dict():
def test_openrouter_reasoning_effort_max_does_not_mutate_caller_dict(reasoning_model: str):
"""
map_openai_params must not mutate the caller-supplied non_default_params dict.
"""
@ -576,14 +579,14 @@ def test_openrouter_reasoning_effort_max_does_not_mutate_caller_dict():
config.map_openai_params(
non_default_params=original_params,
optional_params={},
model="openrouter/deepseek/deepseek-r1",
model=reasoning_model,
drop_params=False,
)
assert original_params["reasoning_effort"] == "max"
def test_openrouter_reasoning_effort_xhigh_passes_through():
def test_openrouter_reasoning_effort_xhigh_passes_through(reasoning_model: str):
"""
reasoning_effort='xhigh' should be forwarded unchanged.
"""
@ -592,14 +595,14 @@ def test_openrouter_reasoning_effort_xhigh_passes_through():
result = config.map_openai_params(
non_default_params={"reasoning_effort": "xhigh"},
optional_params={},
model="openrouter/deepseek/deepseek-r1",
model=reasoning_model,
drop_params=False,
)
assert result["reasoning_effort"] == "xhigh"
def test_openrouter_reasoning_effort_high_passes_through():
def test_openrouter_reasoning_effort_high_passes_through(reasoning_model: str):
"""
Non-max reasoning_effort values should be forwarded unchanged.
"""
@ -608,8 +611,15 @@ def test_openrouter_reasoning_effort_high_passes_through():
result = config.map_openai_params(
non_default_params={"reasoning_effort": "high"},
optional_params={},
model="openrouter/deepseek/deepseek-r1",
model=reasoning_model,
drop_params=False,
)
assert result["reasoning_effort"] == "high"
@pytest.fixture
def reasoning_model(monkeypatch: pytest.MonkeyPatch) -> str:
model: Final = "openrouter/test-reasoning-model"
monkeypatch.setitem(litellm.model_cost, model, {"litellm_provider": "openrouter", "mode": "chat", "supports_reasoning": True})
return model

View file

@ -8,6 +8,9 @@ This test file verifies the fixes for Issue #19923:
"""
from typing import Final
import litellm
import pytest
@ -256,20 +259,14 @@ def test_openrouter_glm_transform_moves_cache_control_to_content():
assert user_message["content"][0]["cache_control"] == {"type": "ephemeral"}
def test_openrouter_supports_thinking_param_for_reasoning_models():
"""OpenRouter should support thinking parameter for reasoning-capable models."""
config = OpenrouterConfig()
def test_openrouter_supports_thinking_param_for_reasoning_models(reasoning_model: str):
supported_params = OpenrouterConfig().get_supported_openai_params(model=reasoning_model)
assert "thinking" in supported_params
assert "reasoning_effort" in supported_params
# Test MiniMax (supports reasoning)
supported_params_minimax = config.get_supported_openai_params(
model="openrouter/minimax/minimax-m2"
)
assert "thinking" in supported_params_minimax
assert "reasoning_effort" in supported_params_minimax
# Test GLM (supports reasoning)
supported_params_glm = config.get_supported_openai_params(
model="openrouter/z-ai/glm-4.6"
)
assert "thinking" in supported_params_glm
assert "reasoning_effort" in supported_params_glm
@pytest.fixture
def reasoning_model(monkeypatch: pytest.MonkeyPatch) -> str:
model: Final = "openrouter/test-reasoning-model"
monkeypatch.setitem(litellm.model_cost, model, {"litellm_provider": "openrouter", "mode": "chat", "supports_reasoning": True})
return model