mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-28 00:00:38 +00:00
* test(e2e): add a Codex compatibility matrix suite Add tests/e2e/client_apps, a compatibility matrix for coding-agent CLIs other than Claude Code, starting with Codex 0.164.0 pinned through npm. Each of the 36 cells drives the real codex exec against the proxy for one feature and provider column, records a pass or fail per model, and the typed matrix builder turns the results into a matrix and flags cells that went from green to red. The harness parts are covered in tests/e2e_harness/client_apps * test(e2e): mark known proxy gaps in the Codex matrix as strict xfails The codex manifest gets a known_gaps list of feature, provider and reason. The client_apps conftest marks each listed cell xfail(strict=True) at collection, so the shared e2e lane stays green while a known gap lasts and goes red when the cell starts passing. The results file still records what the cell did, including crashes under the xfail and a passing strict XPASS. An entry naming a feature or provider the manifest lacks, or a cell listed twice, fails loudly. Web search is listed for all four columns with the proxy behavior behind each failure. * test(e2e): let a Codex known gap be non-strict for intermittent cells A known_gaps entry can now set strict: false (a real bool, default true). That entry marks its cell xfail(strict=False), so the e2e lane stays green whether the cell passes or fails, while the results file still records what happened. Vertex structured output gets a non-strict entry, since gemini-3.8-flash sometimes loops on shell calls or stalls under an output schema and times out. * test(e2e): drop gemini-3.8-flash from the Codex Vertex column and fail vision on shell reads Flash timed out at random on structured output and file edit, and once named the vision color by reading the PNG with PIL. Vertex now runs gemini-4-argon alone, so the non-strict known gap option goes away, and the vision cell fails when the model ran any shell command. * test(e2e): settle the Codex claude_bedrock caching and reasoning cells and skip Mantle web search without the IAM grant * test(e2e): tighten codex known gaps and effort checks, rerun cells once, record the Codex version The reasoning effort row now checks that every logged request asked for high effort and every logged response echoes it or nothing. Known gaps expect only an AssertionError, so a setup error, crash or timeout still fails. Each codex cell reruns once on an AssertionError, and the table keeps the last attempt. The table builder takes --codex-version, refuses a missing table, reports a dropped pass cell as missing, and keeps acronyms in row names * test(e2e): wait for the codex MCP server, turn off pytest-retry, and give codex harness tests unique names Codex sent a turn's first request before the local MCP server was up, so on a resumed turn the model called the vault tool before Codex registered it and the MCP row failed on Claude, Gemini and OpenAI. The harness now marks the server required, so Codex waits for it. pytest-retry, a ci-group plugin, reads the same flaky marker as pytest-rerunfailures and retried crashes too, so tests/e2e/pytest.ini turns it off and the rerun test runs with the real pytest.ini. The new codex harness test files collided with the claude_code ones of the same name at collection, so they take the folder's test_codex_ prefix. * test(e2e): turn off pytest-retry in the codex harness test instead of tests/e2e/pytest.ini A change to tests/e2e/pytest.ini makes CI's e2e picker run every e2e suite on this PR, and the e2e runners do not install pytest-retry, so the line only mattered locally. The codex conftest harness test now passes -p no:pytest-retry itself, and AGENTS.md tells a local run to do the same * test(e2e): expect only a missing feature in codex known gaps and match whole color names in the vision row A strict xfail on a codex setup now expects MissingFeature, which a row raises through require_feature on the check of the feature itself, so a setup error, a Codex crash or any other failed assertion in a known-gap cell still fails. The vision row matches whole color names, so "colored" no longer reads as red. * test(e2e): record the failed first attempt on a codex cell that passed on its rerun The OpenAI and Azure web search xfail reason now names Codex's bundled entry as the cause, served by LiteLLM's model list. * test(e2e): keep a codex known gap's failed first attempt and document the Claude and Gemini real-name check A known gap after a failed attempt now carries first_attempt_error like a pass does. The docs say the real-name row checks that the gateway adds no tool mode for models no Codex catalog lists, the run.py docstring names the lockfile pin, and pytest.ini drops a duplicate meta marker --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
222 lines
8.6 KiB
Python
222 lines
8.6 KiB
Python
from __future__ import annotations
|
|
|
|
from collections.abc import Mapping
|
|
from datetime import datetime, timezone
|
|
from pathlib import Path
|
|
from types import MappingProxyType
|
|
from typing import Final
|
|
|
|
import pytest
|
|
from pydantic import TypeAdapter, ValidationError
|
|
from codex.compat_results import CellResult, Failed, KnownGap, NotTested, Outcome, Passed, append_result
|
|
from codex.matrix_builder import (
|
|
REGRESSION_EXIT_CODE,
|
|
Matrix,
|
|
MatrixRow,
|
|
aggregate,
|
|
build_matrix,
|
|
find_regressions,
|
|
main,
|
|
setup_columns,
|
|
)
|
|
from codex.setups import SETUPS
|
|
|
|
CLAUDE_CODE_SAMPLE: Final = (
|
|
Path(__file__).resolve().parents[2] / "e2e" / "claude_code" / "sample_compatibility-matrix.json"
|
|
)
|
|
GENERATED_AT: Final = datetime(2026, 1, 2, tzinfo=timezone.utc)
|
|
JSON_OBJECT: Final = TypeAdapter(Mapping[str, object])
|
|
JSON_OBJECTS: Final = TypeAdapter(tuple[Mapping[str, object], ...])
|
|
|
|
|
|
def _result(nodeid: str, outcome: Outcome, *, row: str = "vision", setup: str = "openai") -> CellResult:
|
|
return CellResult(nodeid=nodeid, row=row, row_name=row.capitalize(), setup=setup, outcome=outcome)
|
|
|
|
|
|
def _matrix(cells: MappingProxyType[tuple[str, str], Outcome]) -> Matrix:
|
|
rows: Final = sorted(frozenset(row for row, _ in cells))
|
|
return Matrix(
|
|
schema_version="1",
|
|
generated_at=GENERATED_AT.isoformat(),
|
|
litellm_version="1.0.0",
|
|
codex_version="0.1.0",
|
|
providers=tuple(sorted(frozenset(column for _, column in cells))),
|
|
features=tuple(
|
|
MatrixRow(
|
|
id=row,
|
|
name=row.capitalize(),
|
|
providers=MappingProxyType(
|
|
{column: outcome for (cell_row, column), outcome in cells.items() if cell_row == row}
|
|
),
|
|
)
|
|
for row in rows
|
|
),
|
|
)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("outcomes", "expected"),
|
|
(
|
|
((Passed(), Failed(error="a"), Failed(error="b")), Failed(error="a; b")),
|
|
((Passed(), KnownGap(reason="no search route")), KnownGap(reason="no search route")),
|
|
((NotTested(reason="no credentials"), Passed()), Passed()),
|
|
(
|
|
(Passed(first_attempt_error="502"), Passed(), Passed(first_attempt_error="timed out")),
|
|
Passed(first_attempt_error="502; timed out"),
|
|
),
|
|
((Failed(error="401"), Passed(first_attempt_error="502")), Failed(error="401")),
|
|
(
|
|
(
|
|
KnownGap(reason="drops search", first_attempt_error="codex exited 101"),
|
|
Passed(first_attempt_error="502"),
|
|
),
|
|
KnownGap(reason="drops search", first_attempt_error="codex exited 101; 502"),
|
|
),
|
|
((NotTested(reason="no credentials"),), NotTested(reason="no credentials")),
|
|
((), NotTested()),
|
|
),
|
|
)
|
|
def test_a_cell_is_as_bad_as_its_worst_test(outcomes: tuple[Outcome, ...], expected: Outcome) -> None:
|
|
assert aggregate(outcomes) == expected
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("attempts", "expected"),
|
|
(
|
|
((Failed(error="502"), Passed()), Passed(first_attempt_error="502")),
|
|
(
|
|
(Failed(error="codex exited 101"), KnownGap(reason="drops search")),
|
|
KnownGap(reason="drops search", first_attempt_error="codex exited 101"),
|
|
),
|
|
((Passed(), Failed(error="timed out")), Failed(error="timed out")),
|
|
((Passed(),), Passed()),
|
|
),
|
|
)
|
|
def test_the_last_attempt_of_a_test_decides_its_cell(attempts: tuple[Outcome, ...], expected: Outcome) -> None:
|
|
matrix: Final = build_matrix(
|
|
tuple(_result("test_vision_e2e.py::TestCodexVision::test_cell[openai]", outcome) for outcome in attempts),
|
|
columns=("openai", "vertex_ai"),
|
|
litellm_version="1.0.0",
|
|
codex_version="0.1.0",
|
|
generated_at=GENERATED_AT,
|
|
)
|
|
|
|
assert matrix.features[0].providers == {"openai": expected, "vertex_ai": NotTested()}
|
|
|
|
|
|
def test_every_setup_is_a_column_and_an_unknown_setup_is_kept() -> None:
|
|
declared: Final = tuple(setup.id for setup in SETUPS)
|
|
|
|
columns: Final = setup_columns((_result("a", Passed(), setup="zz_new_setup"), _result("b", Passed())))
|
|
|
|
assert columns == (*declared, "zz_new_setup")
|
|
|
|
|
|
def test_regressions_are_cells_that_were_green_and_are_not_anymore() -> None:
|
|
old: Final = _matrix(
|
|
MappingProxyType(
|
|
{
|
|
("vision", "openai"): Passed(),
|
|
("vision", "vertex_ai"): Passed(),
|
|
("vision", "azure_openai"): Passed(),
|
|
("vision", "bedrock_runtime"): Passed(),
|
|
("vision", "bedrock_mantle"): Passed(),
|
|
("web_search", "openai"): Failed(error="old"),
|
|
("web_search", "vertex_ai"): NotTested(),
|
|
("web_search", "azure_openai"): KnownGap(reason="no route"),
|
|
("removed_row", "openai"): Passed(),
|
|
}
|
|
)
|
|
)
|
|
new: Final = _matrix(
|
|
MappingProxyType(
|
|
{
|
|
("vision", "openai"): Failed(error="no image"),
|
|
("vision", "vertex_ai"): KnownGap(reason="drops images"),
|
|
("vision", "azure_openai"): NotTested(reason="no credentials"),
|
|
("vision", "bedrock_runtime"): Passed(),
|
|
("web_search", "openai"): Failed(error="new"),
|
|
("web_search", "vertex_ai"): Failed(error="new"),
|
|
("web_search", "azure_openai"): Passed(),
|
|
("new_row", "openai"): Failed(error="new row"),
|
|
}
|
|
)
|
|
)
|
|
|
|
regressions: Final = find_regressions(old, new)
|
|
|
|
assert frozenset((r.feature_id, r.provider, r.new_status, r.error) for r in regressions) == frozenset(
|
|
(
|
|
("vision", "openai", "fail", "no image"),
|
|
("vision", "vertex_ai", "known_gap", "drops images"),
|
|
("vision", "azure_openai", "not_tested", "no credentials"),
|
|
("vision", "bedrock_mantle", "missing", ""),
|
|
("removed_row", "openai", "missing", ""),
|
|
)
|
|
)
|
|
|
|
|
|
def test_the_matrix_has_the_claude_code_matrix_shape() -> None:
|
|
sample: Final = JSON_OBJECT.validate_json(CLAUDE_CODE_SAMPLE.read_bytes())
|
|
matrix: Final = build_matrix(
|
|
(_result("a", Passed()), _result("b", Failed(error="boom"), setup="vertex_ai")),
|
|
columns=("openai", "vertex_ai"),
|
|
litellm_version="1.0.0",
|
|
codex_version="0.1.0",
|
|
generated_at=GENERATED_AT,
|
|
)
|
|
|
|
built: Final = JSON_OBJECT.validate_json(matrix.model_dump_json(exclude_none=True))
|
|
sample_row: Final = JSON_OBJECTS.validate_python(sample["features"])[0]
|
|
built_row: Final = JSON_OBJECTS.validate_python(built["features"])[0]
|
|
|
|
assert frozenset(built) == (frozenset(sample) - {"claude_code_version"}) | {"codex_version"}
|
|
assert frozenset(built_row) == frozenset(sample_row)
|
|
assert built_row["providers"] == {"openai": {"status": "pass"}, "vertex_ai": {"status": "fail", "error": "boom"}}
|
|
|
|
|
|
def test_cli_builds_the_matrix_and_fails_on_a_regression(tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None:
|
|
green_results: Final = tmp_path / "green.jsonl"
|
|
red_results: Final = tmp_path / "red.jsonl"
|
|
append_result(green_results, _result("a", Passed()))
|
|
append_result(red_results, _result("a", Failed(error="no image")))
|
|
green: Final = tmp_path / "green.json"
|
|
red: Final = tmp_path / "red.json"
|
|
|
|
built: Final = tuple(
|
|
main(
|
|
(
|
|
"build",
|
|
*("--results", str(results), "--out", str(out)),
|
|
*("--litellm-version", "1.2.3", "--codex-version", "0.166.0"),
|
|
)
|
|
)
|
|
for results, out in ((green_results, green), (red_results, red))
|
|
)
|
|
_ = capsys.readouterr()
|
|
steady: Final = main(("regressions", "--old", str(green), "--new", str(green)))
|
|
_ = capsys.readouterr()
|
|
regressed: Final = main(("regressions", "--old", str(green), "--new", str(red)))
|
|
|
|
assert built == (0, 0)
|
|
red_matrix: Final = Matrix.model_validate_json(red.read_bytes())
|
|
assert (red_matrix.litellm_version, red_matrix.codex_version) == ("1.2.3", "0.166.0")
|
|
assert (steady, regressed) == (0, REGRESSION_EXIT_CODE)
|
|
assert JSON_OBJECTS.validate_json(capsys.readouterr().out) == (
|
|
{
|
|
"feature_id": "vision",
|
|
"feature_name": "Vision",
|
|
"provider": "openai",
|
|
"old_status": "pass",
|
|
"new_status": "fail",
|
|
"error": "no image",
|
|
},
|
|
)
|
|
|
|
|
|
def test_cli_refuses_a_baseline_table_that_does_not_exist(tmp_path: Path) -> None:
|
|
new: Final = tmp_path / "new.json"
|
|
_ = new.write_text(_matrix(MappingProxyType({("vision", "openai"): Passed()})).model_dump_json())
|
|
|
|
with pytest.raises(ValidationError, match="old"):
|
|
_ = main(("regressions", "--old", str(tmp_path / "missing.json"), "--new", str(new)))
|