diff --git a/tests/agent/test_codex_ttfb_watchdog.py b/tests/agent/test_codex_ttfb_watchdog.py index d989d69d1e3..983a4cbe4a0 100644 --- a/tests/agent/test_codex_ttfb_watchdog.py +++ b/tests/agent/test_codex_ttfb_watchdog.py @@ -380,7 +380,7 @@ def test_large_codex_request_waits_instead_of_ttfb_reconnect(tmp_path, monkeypat monkeypatch.setattr(agent, "_run_codex_stream", fake_stream) - large_input = "x" * 120_000 # ~30k estimated tokens, above large-request gate. + large_input = "x" * 44_000 # ~11k estimated tokens, above the 10k gate. resp = h.interruptible_api_call(agent, {"model": "gpt-5.5", "input": large_input}) assert resp is sentinel assert "codex_ttfb_kill" not in closes @@ -415,7 +415,7 @@ def test_large_codex_request_strict_ttfb_env_still_reconnects(tmp_path, monkeypa monkeypatch.setattr(agent, "_run_codex_stream", fake_hang) - large_input = "x" * 120_000 + large_input = "x" * 44_000 try: with pytest.raises(TimeoutError) as excinfo: h.interruptible_api_call(agent, {"model": "gpt-5.5", "input": large_input}) diff --git a/tests/agent/test_non_stream_stale_timeout.py b/tests/agent/test_non_stream_stale_timeout.py index 281453db16d..25a74f31c30 100644 --- a/tests/agent/test_non_stream_stale_timeout.py +++ b/tests/agent/test_non_stream_stale_timeout.py @@ -188,3 +188,22 @@ providers: agent = _make_agent(tmp_path) assert agent._compute_non_stream_stale_timeout({"input": "hi"}) == 1800.0 + + +# ── openai-codex gateway-scale stale floor ──────────────────────────────── + + +def test_openai_codex_stale_floor_covers_gateway_tool_payload(): + """Gateway/Telegram tool payloads (~20k tokens) need the 600s Codex floor.""" + from agent.chat_completion_helpers import openai_codex_stale_timeout_floor + + assert openai_codex_stale_timeout_floor(22_095) == 600.0 + assert openai_codex_stale_timeout_floor(10_001) == 600.0 + assert openai_codex_stale_timeout_floor(10_000) == 0.0 + + +def test_openai_codex_stale_floor_tiers(): + from agent.chat_completion_helpers import openai_codex_stale_timeout_floor + + assert openai_codex_stale_timeout_floor(55_000) == 900.0 + assert openai_codex_stale_timeout_floor(120_000) == 1200.0