mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-04 07:31:58 +00:00
fix(codex): update silent-hang workaround hint
This commit is contained in:
parent
976979489a
commit
4243b6dc45
4 changed files with 87 additions and 17 deletions
|
|
@ -102,6 +102,52 @@ def test_ttfb_kills_when_no_stream_event(tmp_path, monkeypatch):
|
|||
stop["flag"] = True
|
||||
|
||||
|
||||
def test_ttfb_includes_silent_hang_hint_for_gpt_5_5(tmp_path, monkeypatch):
|
||||
"""The no-first-byte watchdog should surface the same actionable hint as the
|
||||
stale-call timeout path when the model matches the silent-hang heuristic."""
|
||||
from agent import chat_completion_helpers as h
|
||||
|
||||
agent = _make_codex_agent(tmp_path, monkeypatch)
|
||||
monkeypatch.setenv("HERMES_CODEX_TTFB_TIMEOUT_SECONDS", "1")
|
||||
|
||||
closes: list = []
|
||||
statuses: list[str] = []
|
||||
dummy_client = SimpleNamespace()
|
||||
monkeypatch.setattr(agent, "_create_request_openai_client", lambda **k: dummy_client)
|
||||
monkeypatch.setattr(agent, "_emit_status", lambda msg: statuses.append(msg))
|
||||
monkeypatch.setattr(
|
||||
agent, "_abort_request_openai_client",
|
||||
lambda c, reason=None: closes.append(reason),
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
agent, "_close_request_openai_client",
|
||||
lambda c, reason=None: closes.append(reason),
|
||||
)
|
||||
|
||||
stop = {"flag": False}
|
||||
|
||||
def fake_hang(api_kwargs, client=None, on_first_delta=None):
|
||||
deadline = time.time() + 30
|
||||
while time.time() < deadline and not stop["flag"] and not agent._interrupt_requested:
|
||||
time.sleep(0.02)
|
||||
raise RuntimeError("connection closed")
|
||||
|
||||
monkeypatch.setattr(agent, "_run_codex_stream", fake_hang)
|
||||
|
||||
try:
|
||||
with pytest.raises(TimeoutError) as excinfo:
|
||||
h.interruptible_api_call(agent, {"model": "gpt-5.5", "input": "hi"})
|
||||
message = str(excinfo.value)
|
||||
assert "gpt-5.4" in message
|
||||
assert "gpt-5.3-codex" in message
|
||||
assert "gpt-5.4-codex" in message
|
||||
assert "codex_ttfb_kill" in closes
|
||||
assert statuses, "expected a user-facing watchdog status"
|
||||
assert any("gpt-5.4" in s and "gpt-5.3-codex" in s for s in statuses)
|
||||
finally:
|
||||
stop["flag"] = True
|
||||
|
||||
|
||||
def test_ttfb_does_not_kill_when_events_flow(tmp_path, monkeypatch):
|
||||
"""Once a stream event has arrived, a generation that runs past the TTFB
|
||||
cutoff is NOT killed by the watchdog — it completes normally."""
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
The helper substitutes an actionable hint into the stale-call timeout
|
||||
warning when the request matches a known Codex silent-reject pattern
|
||||
(gpt-5.5 family on the ChatGPT Codex backend). See issue #21444 for
|
||||
symptom history.
|
||||
symptom history. The recommended workaround for ChatGPT Codex OAuth
|
||||
accounts is `gpt-5.4` / `gpt-5.3-codex`, not `gpt-5.4-codex`.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
|
@ -43,6 +44,8 @@ def test_hint_fires_for_bare_gpt_5_5_on_codex(tmp_path):
|
|||
agent.api_mode = "codex_responses"
|
||||
hint = agent._codex_silent_hang_hint(model="gpt-5.5")
|
||||
assert hint is not None
|
||||
assert "gpt-5.4" in hint
|
||||
assert "gpt-5.3-codex" in hint
|
||||
assert "gpt-5.4-codex" in hint
|
||||
assert "fallback chain" in hint
|
||||
|
||||
|
|
@ -72,11 +75,11 @@ def test_hint_fires_when_model_arg_omitted(tmp_path):
|
|||
# ── negative cases: hint stays None ────────────────────────────────────────
|
||||
|
||||
|
||||
def test_hint_skipped_for_gpt_5_4_codex(tmp_path):
|
||||
"""gpt-5.4-codex is the recommended workaround — must not trigger."""
|
||||
agent = _make_agent(tmp_path, model="gpt-5.4-codex")
|
||||
def test_hint_skipped_for_gpt_5_4(tmp_path):
|
||||
"""gpt-5.4 is the recommended workaround — must not trigger."""
|
||||
agent = _make_agent(tmp_path, model="gpt-5.4")
|
||||
agent.api_mode = "codex_responses"
|
||||
assert agent._codex_silent_hang_hint(model="gpt-5.4-codex") is None
|
||||
assert agent._codex_silent_hang_hint(model="gpt-5.4") is None
|
||||
|
||||
|
||||
def test_hint_skipped_for_gpt_5_50_false_positive(tmp_path):
|
||||
|
|
@ -107,11 +110,11 @@ def test_hint_skipped_for_non_codex_provider(tmp_path):
|
|||
|
||||
def test_hint_skipped_for_empty_model(tmp_path):
|
||||
"""Explicit empty string ``model`` short-circuits the regex."""
|
||||
agent = _make_agent(tmp_path, model="gpt-5.4-codex") # self.model non-matching
|
||||
agent = _make_agent(tmp_path, model="gpt-5.4") # self.model non-matching
|
||||
agent.api_mode = "codex_responses"
|
||||
# Explicit empty string: regex won't match
|
||||
assert agent._codex_silent_hang_hint(model="") is None
|
||||
# model=None falls back to self.model which is gpt-5.4-codex, also no match
|
||||
# model=None falls back to self.model which is gpt-5.4, also no match
|
||||
assert agent._codex_silent_hang_hint(model=None) is None
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue