Repository navigation
test(ci): add reasoning_effort grid e2e regression suite #28036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yuneng-berri
merged 12 commits into
litellm_internal_staging
from
litellm_grid-v4-e2e-tests-cZRwz
May 16, 2026
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fec4ae6
test(ci): add reasoning_effort grid v4 e2e regression suite
mateo-berri 4327427
fix(reasoning_effort_grid_v4): cleanup unused fixture, parse converse…
cursoragent 51dff1f
fix(reasoning_effort_grid_v4): grant sonnet-4-6 entries the max-effor…
cursoragent f77324d
refactor(tests): move reasoning_effort grid suite under llm_translati…
mateo-berri d084782
Merge branch 'litellm_grid-v4-e2e-tests-cZRwz' of http://127.0.0.1:41…
mateo-berri 90cdbb9
fix(tests): use litellm.anthropic_messages entrypoint + drop unstable…
mateo-berri e29ea53
fix(reasoning_effort_grid): classify status by exception status_code,…
mateo-berri 2b00ea9
test(ci): skip Fireworks tests on 404 + Gemini image-size test on 429
mateo-berri 18c9322
fix(test_gemini): skip after pytest.raises catches the 429-wrapped Im…
mateo-berri fb7091e
refactor(reasoning_effort_grid): tighten test helpers per Greptile re…
mateo-berri f9485f1
refactor: strip PR-introduced docstrings and explanatory comments
mateo-berri 4e8ac31
Merge branch 'litellm_internal_staging' into litellm_grid-v4-e2e-test…
mateo-berri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| from typing import Any, Dict, List, Optional | ||
|
|
||
| import pytest | ||
|
|
||
| import litellm | ||
| from litellm.integrations.custom_logger import CustomLogger | ||
|
|
||
|
|
||
| class _WireBodyCapture(CustomLogger): | ||
| def __init__(self) -> None: | ||
| super().__init__() | ||
| self.records: List[Dict[str, Any]] = [] | ||
|
|
||
| def log_pre_api_call(self, model, messages, kwargs): | ||
| self.records.append( | ||
| { | ||
| "model": model, | ||
| "body": kwargs.get("additional_args", {}).get("complete_input_dict"), | ||
| "api_base": kwargs.get("additional_args", {}).get("api_base"), | ||
| } | ||
| ) | ||
|
|
||
| async def async_log_pre_api_call(self, model, messages, kwargs): | ||
| self.log_pre_api_call(model, messages, kwargs) | ||
|
|
||
| def latest(self) -> Optional[Dict[str, Any]]: | ||
| return self.records[-1] if self.records else None | ||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def wire_capture(): | ||
| capture = _WireBodyCapture() | ||
| previous = list(litellm.callbacks) | ||
| litellm.callbacks = previous + [capture] | ||
| try: | ||
| yield capture | ||
| finally: | ||
| litellm.callbacks = previous |
289 changes: 289 additions & 0 deletions
289
tests/llm_translation/reasoning_effort_grid/grid_spec.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,289 @@ | ||
| from dataclasses import dataclass, field | ||
| from typing import Dict, FrozenSet, List, Optional, Tuple | ||
|
|
||
|
|
||
| OMIT = object() | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class CellExpectation: | ||
| status: int | ||
| thinking_type: object | ||
| output_config_effort: object = OMIT | ||
| thinking_budget_tokens: object = OMIT | ||
| max_tokens: object = OMIT | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class ModelEntry: | ||
| alias: str | ||
| model: str | ||
| mode: str | ||
| extra_params: Tuple[Tuple[str, str], ...] = field(default_factory=tuple) | ||
| required_env: FrozenSet[str] = field(default_factory=frozenset) | ||
| caps: FrozenSet[str] = field(default_factory=frozenset) | ||
|
|
||
| def params(self) -> Dict[str, str]: | ||
| return dict(self.extra_params) | ||
|
|
||
|
|
||
| EFFORTS: Tuple[str, ...] = ( | ||
| "__omit__", | ||
| "none", | ||
| "minimal", | ||
| "low", | ||
| "medium", | ||
| "high", | ||
| "xhigh", | ||
| "max", | ||
| "disabled", | ||
| "invalid", | ||
| "", | ||
| ) | ||
|
|
||
| _BUDGET_TOKENS: Dict[str, int] = { | ||
| "minimal": 1024, | ||
| "low": 1024, | ||
| "medium": 2048, | ||
| "high": 4096, | ||
| "xhigh": 8192, | ||
| "max": 16384, | ||
| } | ||
|
|
||
| _ADAPTIVE_EFFORT_LABEL: Dict[str, str] = { | ||
| "minimal": "low", | ||
| "low": "low", | ||
| "medium": "medium", | ||
| "high": "high", | ||
| "xhigh": "xhigh", | ||
| "max": "max", | ||
| } | ||
|
|
||
| _BAD_REQUEST_EFFORTS: FrozenSet[str] = frozenset({"disabled", "invalid", ""}) | ||
|
|
||
|
|
||
| def expected(model: ModelEntry, effort: str) -> CellExpectation: | ||
| if effort in ("__omit__", "none"): | ||
| if model.mode == "budget": | ||
| return CellExpectation(status=200, thinking_type=OMIT, max_tokens=8192) | ||
| return CellExpectation(status=200, thinking_type=OMIT) | ||
|
|
||
| if effort in _BAD_REQUEST_EFFORTS: | ||
| return CellExpectation(status=400, thinking_type=OMIT) | ||
|
|
||
| if effort in ("xhigh", "max"): | ||
| cap = f"supports_{effort}_reasoning_effort" | ||
| if cap not in model.caps: | ||
| return CellExpectation(status=400, thinking_type=OMIT) | ||
|
|
||
| if model.mode == "adaptive": | ||
| return CellExpectation( | ||
| status=200, | ||
| thinking_type="adaptive", | ||
| output_config_effort=_ADAPTIVE_EFFORT_LABEL[effort], | ||
| ) | ||
|
|
||
| return CellExpectation( | ||
| status=200, | ||
| thinking_type="enabled", | ||
| thinking_budget_tokens=_BUDGET_TOKENS[effort], | ||
| max_tokens=8192, | ||
| ) | ||
|
|
||
|
|
||
| _ANTHROPIC_REQ = frozenset({"ANTHROPIC_API_KEY"}) | ||
| _AZURE_FOUNDRY_REQ = frozenset({"AZURE_FOUNDRY_API_BASE", "AZURE_FOUNDRY_API_KEY"}) | ||
| _VERTEX_REQ = frozenset({"VERTEX_PROJECT"}) | ||
| _BEDROCK_REQ = frozenset({"AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY"}) | ||
|
|
||
|
|
||
| _CAPS_OPUS_4_7: FrozenSet[str] = frozenset( | ||
| {"supports_xhigh_reasoning_effort", "supports_max_reasoning_effort"} | ||
| ) | ||
| _CAPS_4_6: FrozenSet[str] = frozenset({"supports_max_reasoning_effort"}) | ||
| _CAPS_NONE: FrozenSet[str] = frozenset() | ||
|
|
||
|
|
||
| ANTHROPIC_DIRECT_MODELS: Tuple[ModelEntry, ...] = ( | ||
| ModelEntry( | ||
| alias="claude-opus-4-7", | ||
| model="anthropic/claude-opus-4-7", | ||
| mode="adaptive", | ||
| required_env=_ANTHROPIC_REQ, | ||
| caps=_CAPS_OPUS_4_7, | ||
| ), | ||
| ModelEntry( | ||
| alias="claude-sonnet-4-6", | ||
| model="anthropic/claude-sonnet-4-6", | ||
| mode="adaptive", | ||
| required_env=_ANTHROPIC_REQ, | ||
| caps=_CAPS_4_6, | ||
| ), | ||
|
cursor[bot] marked this conversation as resolved.
Resolved
|
||
| ModelEntry( | ||
| alias="claude-haiku-4-5", | ||
| model="anthropic/claude-haiku-4-5", | ||
| mode="budget", | ||
| required_env=_ANTHROPIC_REQ, | ||
| caps=_CAPS_NONE, | ||
| ), | ||
| ) | ||
|
|
||
|
|
||
| AZURE_AI_MODELS: Tuple[ModelEntry, ...] = ( | ||
| ModelEntry( | ||
| alias="azure-claude-opus-4-7", | ||
| model="azure_ai/claude-opus-4-7", | ||
| mode="adaptive", | ||
| required_env=_AZURE_FOUNDRY_REQ, | ||
| caps=_CAPS_OPUS_4_7, | ||
| ), | ||
| ModelEntry( | ||
| alias="azure-claude-opus-4-6", | ||
| model="azure_ai/claude-opus-4-6", | ||
| mode="adaptive", | ||
| required_env=_AZURE_FOUNDRY_REQ, | ||
| caps=_CAPS_4_6, | ||
| ), | ||
| ModelEntry( | ||
| alias="azure-claude-sonnet-4-6", | ||
| model="azure_ai/claude-sonnet-4-6", | ||
| mode="adaptive", | ||
| required_env=_AZURE_FOUNDRY_REQ, | ||
| caps=_CAPS_4_6, | ||
| ), | ||
| ModelEntry( | ||
| alias="azure-claude-haiku-4-5", | ||
| model="azure_ai/claude-haiku-4-5", | ||
| mode="budget", | ||
| required_env=_AZURE_FOUNDRY_REQ, | ||
| caps=_CAPS_NONE, | ||
| ), | ||
| ) | ||
|
|
||
|
|
||
| VERTEX_AI_MODELS: Tuple[ModelEntry, ...] = ( | ||
| ModelEntry( | ||
| alias="vertex-claude-opus-4-7", | ||
| model="vertex_ai/claude-opus-4-7", | ||
| mode="adaptive", | ||
| extra_params=(("vertex_location", "global"),), | ||
| required_env=_VERTEX_REQ, | ||
| caps=_CAPS_OPUS_4_7, | ||
| ), | ||
| ModelEntry( | ||
| alias="vertex-claude-opus-4-6", | ||
| model="vertex_ai/claude-opus-4-6", | ||
| mode="adaptive", | ||
| extra_params=(("vertex_location", "us-east5"),), | ||
| required_env=_VERTEX_REQ, | ||
| caps=_CAPS_4_6, | ||
| ), | ||
| ModelEntry( | ||
| alias="vertex-claude-sonnet-4-6", | ||
| model="vertex_ai/claude-sonnet-4-6", | ||
| mode="adaptive", | ||
| extra_params=(("vertex_location", "us-east5"),), | ||
| required_env=_VERTEX_REQ, | ||
| caps=_CAPS_4_6, | ||
| ), | ||
| ModelEntry( | ||
| alias="vertex-claude-haiku-4-5", | ||
| model="vertex_ai/claude-haiku-4-5", | ||
| mode="budget", | ||
| extra_params=(("vertex_location", "us-east5"),), | ||
| required_env=_VERTEX_REQ, | ||
| caps=_CAPS_NONE, | ||
| ), | ||
| ) | ||
|
|
||
|
|
||
| BEDROCK_CONVERSE_MODELS: Tuple[ModelEntry, ...] = ( | ||
| ModelEntry( | ||
| alias="bedrock-claude-opus-4-7", | ||
| model="bedrock/converse/us.anthropic.claude-opus-4-7", | ||
| mode="adaptive", | ||
| extra_params=(("aws_region_name", "us-east-1"),), | ||
| required_env=_BEDROCK_REQ, | ||
| caps=_CAPS_OPUS_4_7, | ||
| ), | ||
| ModelEntry( | ||
| alias="bedrock-claude-opus-4-6", | ||
| model="bedrock/converse/us.anthropic.claude-opus-4-6-v1", | ||
| mode="adaptive", | ||
| extra_params=(("aws_region_name", "us-east-1"),), | ||
| required_env=_BEDROCK_REQ, | ||
| caps=_CAPS_4_6, | ||
| ), | ||
| ModelEntry( | ||
| alias="bedrock-claude-sonnet-4-6", | ||
| model="bedrock/converse/us.anthropic.claude-sonnet-4-6", | ||
| mode="adaptive", | ||
| extra_params=(("aws_region_name", "us-east-1"),), | ||
| required_env=_BEDROCK_REQ, | ||
| caps=_CAPS_4_6, | ||
| ), | ||
| ModelEntry( | ||
| alias="bedrock-claude-sonnet-4-5", | ||
| model="bedrock/converse/us.anthropic.claude-sonnet-4-5-20250929-v1:0", | ||
| mode="budget", | ||
| extra_params=(("aws_region_name", "us-east-1"),), | ||
| required_env=_BEDROCK_REQ, | ||
| caps=_CAPS_NONE, | ||
| ), | ||
| ) | ||
|
|
||
|
|
||
| BEDROCK_INVOKE_CHAT_MODELS: Tuple[ModelEntry, ...] = ( | ||
| ModelEntry( | ||
| alias="bedrock-invoke-claude-opus-4-6", | ||
| model="bedrock/invoke/us.anthropic.claude-opus-4-6-v1", | ||
| mode="adaptive", | ||
| extra_params=(("aws_region_name", "us-east-1"),), | ||
| required_env=_BEDROCK_REQ, | ||
| caps=_CAPS_4_6, | ||
| ), | ||
| ModelEntry( | ||
| alias="bedrock-invoke-claude-sonnet-4-6", | ||
| model="bedrock/invoke/us.anthropic.claude-sonnet-4-6", | ||
| mode="adaptive", | ||
| extra_params=(("aws_region_name", "us-east-1"),), | ||
| required_env=_BEDROCK_REQ, | ||
| caps=_CAPS_4_6, | ||
| ), | ||
| ModelEntry( | ||
| alias="bedrock-invoke-claude-opus-4-5", | ||
| model="bedrock/invoke/us.anthropic.claude-opus-4-5-20251101-v1:0", | ||
| mode="budget", | ||
| extra_params=(("aws_region_name", "us-east-1"),), | ||
| required_env=_BEDROCK_REQ, | ||
| caps=_CAPS_NONE, | ||
| ), | ||
| ) | ||
|
|
||
|
|
||
| BEDROCK_INVOKE_MESSAGES_MODELS: Tuple[ModelEntry, ...] = BEDROCK_INVOKE_CHAT_MODELS | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class Route: | ||
| name: str | ||
| models: Tuple[ModelEntry, ...] | ||
|
|
||
|
|
||
| ROUTES: Tuple[Route, ...] = ( | ||
| Route("anthropic_direct", ANTHROPIC_DIRECT_MODELS), | ||
| Route("azure_ai", AZURE_AI_MODELS), | ||
| Route("vertex_ai", VERTEX_AI_MODELS), | ||
| Route("bedrock_converse", BEDROCK_CONVERSE_MODELS), | ||
| Route("bedrock_invoke_chat", BEDROCK_INVOKE_CHAT_MODELS), | ||
| Route("bedrock_invoke_messages", BEDROCK_INVOKE_MESSAGES_MODELS), | ||
| ) | ||
|
|
||
|
|
||
| def all_cells() -> List[Tuple[str, ModelEntry, str, CellExpectation]]: | ||
| cells: List[Tuple[str, ModelEntry, str, CellExpectation]] = [] | ||
| for route in ROUTES: | ||
| for model in route.models: | ||
| for effort in EFFORTS: | ||
| cells.append((route.name, model, effort, expected(model, effort))) | ||
| return cells | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.