Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 20 additions & 28 deletions tests/agent/test_reasoning_stale_timeout_floor.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,13 @@ def test_reasoning_floor_applies_to_nemotron_3_ultra(monkeypatch, tmp_path):
monkeypatch.delenv("HERMES_API_CALL_STALE_TIMEOUT", raising=False)
_write_config(tmp_path, "")

# Clear any cached config from prior tests in this session.
import importlib
from hermes_cli import config as cfg_mod, timeouts as to_mod
importlib.reload(cfg_mod)
importlib.reload(to_mod)
# Isolate the floor path from leaked provider config: with no per-model /
# per-provider stale_timeout_seconds, the resolver falls through to the
# reasoning floor. Patch the lookup to return None deterministically
# rather than relying on importlib.reload of shared config modules, which
# races other tests in the same xdist worker (#52217 flake).
import run_agent
monkeypatch.setattr(run_agent, "get_provider_stale_timeout", lambda *a, **k: None)

agent = _make_agent(
tmp_path,
Expand All @@ -190,10 +192,9 @@ def test_reasoning_floor_applies_to_opus_4_thinking(monkeypatch, tmp_path):
monkeypatch.delenv("HERMES_API_CALL_STALE_TIMEOUT", raising=False)
_write_config(tmp_path, "")

import importlib
from hermes_cli import config as cfg_mod, timeouts as to_mod
importlib.reload(cfg_mod)
importlib.reload(to_mod)
# Deterministic floor path — see test_reasoning_floor_applies_to_nemotron_3_ultra.
import run_agent
monkeypatch.setattr(run_agent, "get_provider_stale_timeout", lambda *a, **k: None)

agent = _make_agent(
tmp_path,
Expand All @@ -216,19 +217,12 @@ def test_reasoning_floor_never_overrides_explicit_user_config(monkeypatch, tmp_p
"""
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
(tmp_path / ".env").write_text("", encoding="utf-8")
_write_config(tmp_path, """\
providers:
nvidia:
models:
nvidia/nemotron-3-ultra-550b-a55b:
stale_timeout_seconds: 60
""")
monkeypatch.delenv("HERMES_API_CALL_STALE_TIMEOUT", raising=False)

import importlib
from hermes_cli import config as cfg_mod, timeouts as to_mod
importlib.reload(cfg_mod)
importlib.reload(to_mod)
# Explicit per-model config resolves to 60s (priority 1). The resolver
# must short-circuit on this and never consult the reasoning floor.
import run_agent
monkeypatch.setattr(run_agent, "get_provider_stale_timeout", lambda *a, **k: 60.0)

agent = _make_agent(
tmp_path,
Expand All @@ -251,10 +245,9 @@ def test_reasoning_floor_loses_to_env_var_when_no_floor_match(monkeypatch, tmp_p
monkeypatch.setenv("HERMES_API_CALL_STALE_TIMEOUT", "300")
_write_config(tmp_path, "")

import importlib
from hermes_cli import config as cfg_mod, timeouts as to_mod
importlib.reload(cfg_mod)
importlib.reload(to_mod)
# No provider config -> resolver consults the env var (priority 3).
import run_agent
monkeypatch.setattr(run_agent, "get_provider_stale_timeout", lambda *a, **k: None)

agent = _make_agent(
tmp_path,
Expand All @@ -274,10 +267,9 @@ def test_non_reasoning_model_keeps_default(monkeypatch, tmp_path):
monkeypatch.delenv("HERMES_API_CALL_STALE_TIMEOUT", raising=False)
_write_config(tmp_path, "")

import importlib
from hermes_cli import config as cfg_mod, timeouts as to_mod
importlib.reload(cfg_mod)
importlib.reload(to_mod)
# No provider config, no env var, no floor match -> 90s implicit default.
import run_agent
monkeypatch.setattr(run_agent, "get_provider_stale_timeout", lambda *a, **k: None)

agent = _make_agent(
tmp_path,
Expand Down
Loading