Skip to content

The agent that grows with you

fix(codex): proxy override survives credential rotation and model.base_url is honoured

rjshrjndrn7034628c923f
diff --git a/agent/credential_pool.py b/agent/credential_pool.py
index f40fe2fd92a..56de2f87408 100644
--- a/agent/credential_pool.py
+++ b/agent/credential_pool.py
@@ -19,7 +19,7 @@ from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Tuple
from hermes_constants import OPENROUTER_BASE_URL
from hermes_cli.config import load_env
-from agent.secret_scope import get_secret as _get_secret
+from agent.secret_scope import get_secret as _get_secret, get_secret_str
from agent.retry_utils import reset_delay_from_message
from agent.credential_persistence import (
fingerprint_secret_value,
@@ -297,6 +297,11 @@ class PooledCredential:
def runtime_base_url(self) -> Optional[str]:
if self.provider == "nous":
return self.inference_base_url or self.base_url
+ if self.provider == "openai-codex":
+ # Pool rows keep the canonical ChatGPT URL; the profile-scoped proxy override must win
+ # for every reader of the row — initial resolution AND a 401/429 rotation
+ # (client_lifecycle._swap_credential), or a rotation silently leaves the proxy.
+ return get_secret_str("HERMES_CODEX_BASE_URL", "").strip().rstrip("/") or self.base_url
return self.base_url
diff --git a/contributors/emails/[email protected] b/contributors/emails/[email protected]
new file mode 100644
index 00000000000..2dde3763dbb
--- /dev/null
+++ b/contributors/emails/[email protected]
@@ -0,0 +1 @@
+rjshrjndrn
diff --git a/hermes_cli/runtime_provider.py b/hermes_cli/runtime_provider.py
index f4f62c1201c..5e90d901bb1 100644
--- a/hermes_cli/runtime_provider.py
+++ b/hermes_cli/runtime_provider.py
@@ -492,6 +492,10 @@ def _pool_entry_mode_and_url(provider, entry, model_cfg, effective_model, base_u
override_url = get_secret_str("HERMES_CODEX_BASE_URL", "").strip().rstrip("/")
if override_url:
return api_mode, override_url
+ # model.base_url is the secondary proxy override (same rule as the generic tail below:
+ # only when the pool row still carries the canonical URL).
+ if base_url in ("", default_url):
+ base_url = _config_base_url_for_provider(model_cfg, provider) or base_url
return api_mode, base_url or (default_url() if callable(default_url) else default_url)
if provider == "anthropic":
return "anthropic_messages", _anthropic_cfg_base_url(model_cfg) or base_url or _ANTHROPIC_DEFAULT_BASE_URL