Skip to content

The agent that grows with you

fix(router): pytest guard on caps warmer + debug log in fail-open efforts lookup

kshitijk4poor1c5ee5815fe5
diff --git a/agent/transports/codex.py b/agent/transports/codex.py
index 13ce4ff9599..eff74dca1c5 100644
--- a/agent/transports/codex.py
+++ b/agent/transports/codex.py
@@ -7,9 +7,12 @@ streaming, or the _run_codex_stream() call path.
import hashlib
import json
+import logging
import re
from typing import Any, Dict, List, Optional
+logger = logging.getLogger(__name__)
+
# Cron fires build session_id as ``cron_<job_id>_<YYYYMMDD_HHMMSS>`` (see
# cron/scheduler.py). The trailing timestamp is per-fire noise; stripped so
# repeat fires of the same job share a cache scope (see #51395/#52295).
@@ -272,7 +275,10 @@ def _profile_declared_efforts(
inferred_profile = get_provider_profile(inferred)
if inferred_profile is not None:
declared = inferred_profile.supported_reasoning_efforts(model)
- except Exception:
+ except Exception as exc:
+ # Fail-open by design: a broken profile hook must never block the
+ # request — the transport falls back to its default vocabulary.
+ logger.debug("profile-declared efforts lookup failed: %s", exc)
return None
if declared is None:
return None
diff --git a/plugins/model-providers/router/__init__.py b/plugins/model-providers/router/__init__.py
index d1806d5883f..6e5b21dc2de 100644
--- a/plugins/model-providers/router/__init__.py
+++ b/plugins/model-providers/router/__init__.py
@@ -279,6 +279,10 @@ def _efforts_cache_only() -> Optional[dict[str, list[str]]]:
def _warm_efforts_async() -> None:
"""Refresh the efforts cache in the background, at most once per process."""
global _warm_started
+ if os.environ.get("PYTEST_CURRENT_TEST"):
+ # Match the canonical caps warmer (hermes_cli/models.py): a mid-suite
+ # background fetch would make cache state timing-dependent in tests.
+ return
with _efforts_lock:
if _warm_started:
return