Skip to content

fix(agent): raw_codex client uses runtime-resolved base_url - #5988

Open
Tranquil-Flow wants to merge 1 commit into
NousResearch:mainfrom
Tranquil-Flow:review/codex-raw-client-ready
Open

fix(agent): raw_codex client uses runtime-resolved base_url#5988
Tranquil-Flow wants to merge 1 commit into
NousResearch:mainfrom
Tranquil-Flow:review/codex-raw-client-ready

Conversation

@Tranquil-Flow

@Tranquil-Flow Tranquil-Flow commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

resolve_provider_client() was hardcoding _CODEX_AUX_BASE_URL for the raw_codex=True path, ignoring any custom base URL set via HERMES_CODEX_BASE_URL or a Codex-compatible proxy. This change calls resolve_codex_runtime_credentials() (the same resolver used by the non-raw path) so custom proxies and load balancers work correctly.

Related Issue

Fixes #5875

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • agent/auxiliary_client.py — targeted fix in resolve_provider_client() so the raw_codex=True path uses resolve_codex_runtime_credentials() instead of the hardcoded base URL constant
  • tests/agent/test_auxiliary_client.py — regression test covering runtime-resolved base_url for the raw Codex client

How to Test

  1. pytest tests/agent/test_auxiliary_client.py — passes
  2. With HERMES_CODEX_BASE_URL set to a proxy URL, confirm raw_codex=True sessions hit the custom endpoint correctly

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 15 (Darwin 24.6.0)

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

$ pytest tests/agent/test_auxiliary_client.py

@blasai1739217-cmyk

Copy link
Copy Markdown

Friendly bump on this PR in case it fell through the cracks \u2014 would love a review when someone has a minute. Thanks!

Zijie-Tian added a commit to Zijie-Tian/hermes-agent that referenced this pull request Apr 18, 2026
The main OpenAI client path was injecting a custom httpx transport that
bypassed proxy-aware defaults, while the raw Codex path ignored
runtime-resolved base URLs and openai-codex callers could still pin
chat_completions. This packages the minimal local fixes and regression
tests needed to make Hermes reliably use Codex gpt-5.4 behind the
user's configured proxy.

Constraint: Must preserve unrelated local edits in the repo
Constraint: Must keep Hermes on the Codex Responses path for openai-codex
Rejected: Commit workspace-level ~/.hermes/.env changes | outside repo scope
Rejected: Wait for upstream PR merges | user needs a working fork branch now
Confidence: high
Scope-risk: moderate
Reversibility: clean
Directive: If upstream merges NousResearch#11733/NousResearch#10044/NousResearch#5988, rebase this branch against their final versions before reusing it
Tested: pytest tests/run_agent/test_create_openai_client_reuse.py -q
Tested: pytest tests/run_agent/test_run_agent_codex_responses.py -q
Tested: pytest tests/agent/test_auxiliary_client.py -q
Tested: hermes chat --provider openai-codex -m gpt-5.4 -Q --max-turns 1 -q "Reply with exactly OK."
Tested: hermes chat -Q --max-turns 1 -q "Reply with exactly OK."
Not-tested: gateway / IM platform flows
Related: NousResearch#11609
Related: NousResearch#11733
Related: NousResearch#10044
Related: NousResearch#5988
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint labels Apr 30, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #15855 — both fix #5875 (raw_codex base_url resolution). Same root cause in resolve_provider_client().

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for addressing the live raw-Codex routing defect. Current main still constructs raw Codex clients with the fixed endpoint at agent/auxiliary_client.py:4574-4588, while the main-agent initialization reaches that branch through agent/agent_init.py:953.

Problems

  • The same runtime override remains absent from the non-raw Codex path: resolve_provider_client() calls _build_codex_client() at agent/auxiliary_client.py:4590, and that helper still uses _CODEX_AUX_BASE_URL for singleton credentials at agent/auxiliary_client.py:2469 and agent/auxiliary_client.py:2474.
  • The new test stubs the resolver, so it does not prove that HERMES_CODEX_BASE_URL reaches the constructed client through the actual auth-store resolver (hermes_cli/auth.py:3718-3726).

Suggested changes

  • Reuse resolve_codex_runtime_credentials() in _build_codex_client() too, retaining the existing adapter behavior.
  • Add a temp-HERMES_HOME integration regression covering the environment override for both raw and wrapped Codex client construction.

This is an automated hermes-sweeper review.

@alt-glitch alt-glitch added provider/openai OpenAI / Codex Responses API area/auth Authentication, OAuth, credential pools labels Jul 12, 2026
@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 12, 2026
@alt-glitch alt-glitch removed the sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades label Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools codex comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists provider/openai OpenAI / Codex Responses API sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: openai-codex main agent path ignores resolved custom base_url when raw_codex=true

4 participants