litellm/tests/e2e/codex/test_real_model_name_e2e.py
ryan-crabbe-berri 29b81cdf54
test(e2e): run codex under the real model name as a team model, round trip and compaction (#49896)
* test(e2e): run codex in fast mode under the real model name as a team model

Each test registers its deployment as a team model named after the real model, on a throwaway team with a
team key, so parallel tests never share one pooled deployment. Fast mode sets service_tier to priority the
way /fast does and must still answer with a value only reachable through the gateway, on every setup

* test(e2e): run codex round trip and compaction under the real model name

Adds the real-name round trip, which first checks Codex got its own catalog entry for that provider, and
the two-turn compaction row. Both compaction tests now also require each turn to exit 0
2026-11-21 23:54:26 +00:00

57 lines
2.6 KiB
Python

from __future__ import annotations
from typing import Final
import pytest
from codex.harness import CodexHarness
from codex.setups import SETUPS, Deployment, ModelSetup
from e2e_config import unique_marker
pytestmark = pytest.mark.e2e
COMPACT_AFTER_TOKENS: Final = 500
PADDING: Final = "".join(f"line {number}: the quick brown fox jumps over the lazy dog\n" for number in range(400))
class TestCodexUnderTheRealModelName:
@pytest.mark.parametrize("deployment", SETUPS)
def test_answers_with_what_a_command_printed(
self, deployment: Deployment, real_name_codex: CodexHarness, real_name_setup: ModelSetup
) -> None:
served_by_gateway: Final = real_name_codex.tool_modes()
codex_own: Final = real_name_codex.tool_modes(deployment.codex_entry.catalog)
assert served_by_gateway[real_name_setup.model] == codex_own.get(deployment.codex_entry.slug)
marker: Final = unique_marker()
workspace: Final = real_name_codex.new_workspace(files={"secret.txt": marker})
run: Final = real_name_codex.exec(
"Run `cat secret.txt`, then reply with exactly what it printed.", model=real_name_setup.model, cwd=workspace
)
assert run.exit_code == 0, run
assert any(marker in command.output for command in run.commands), run
assert marker in run.answer, run
@pytest.mark.parametrize("deployment", SETUPS)
def test_remembers_a_value_after_the_gateway_compacts_the_session(
self, real_name_codex: CodexHarness, real_name_setup: ModelSetup
) -> None:
marker: Final = unique_marker()
workspace: Final = real_name_codex.new_workspace(files={"secret.txt": marker, "padding.txt": PADDING})
first: Final = real_name_codex.exec(
"Run `cat secret.txt` and remember the value it prints. Then run `cat padding.txt`. Then reply with OK.",
model=real_name_setup.model,
cwd=workspace,
compact_after_tokens=COMPACT_AFTER_TOKENS,
)
assert first.exit_code == 0, first
assert first.thread_id is not None, first
(workspace / "secret.txt").unlink()
second: Final = real_name_codex.resume(
first.thread_id,
"What value did secret.txt print earlier? Reply with just that value.",
model=real_name_setup.model,
cwd=workspace,
compact_after_tokens=COMPACT_AFTER_TOKENS,
)
assert second.exit_code == 0, second
assert any(compaction.remote for compaction in real_name_codex.compactions(first.thread_id)), (first, second)
assert marker in second.answer, second