Skip to content

fix(agent): preserve custom codex provider aliases#17498

Closed
zhonghui5207 wants to merge 1 commit into
NousResearch:mainfrom
zhonghui5207:codex/fix-custom-codex-alias
Closed

fix(agent): preserve custom codex provider aliases#17498
zhonghui5207 wants to merge 1 commit into
NousResearch:mainfrom
zhonghui5207:codex/fix-custom-codex-alias

Conversation

@zhonghui5207

@zhonghui5207 zhonghui5207 commented Apr 29, 2026

Copy link
Copy Markdown

What does this PR do?

Fixes auxiliary provider resolution when a user-defined provider is named codex.

Before this change, resolve_provider_client() normalized aliases before checking named custom providers:

custom:codex -> codex -> openai-codex
codex        -> openai-codex

That meant a configured local/custom endpoint named codex was bypassed and Hermes tried to find OpenAI Codex OAuth credentials instead. This PR gives the raw requested provider name a chance to resolve against providers: / custom_providers: before the built-in codex -> openai-codex alias wins.

The existing alias behavior is preserved when no custom provider named codex exists.

Related Issue

Fixes #17488

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
    • Preserve the raw requested provider string in resolve_provider_client().
    • Resolve named custom providers with that raw name before built-in aliases route to OAuth-backed providers.
    • Keep the normalized-provider custom lookup so existing named-provider behavior remains intact.
  • tests/agent/test_auxiliary_named_custom_providers.py
    • Add regression coverage for a custom provider named codex.
    • Add coverage for explicit custom:codex.
    • Add coverage that bare codex still resolves to built-in openai-codex when no custom provider shadows it.

How to Test

  1. Configure a custom provider named codex:

    model:
      default: gpt-5.4
      provider: codex
    
    custom_providers:
      - name: codex
        base_url: http://127.0.0.1:8317/api/provider/codex
        api_key: ccs-internal-managed
        model: gpt-5.4
  2. Resolve an auxiliary client for codex.

  3. Confirm it uses the configured custom endpoint instead of the built-in openai-codex OAuth path.

Automated checks run:

PYTHONPATH=/private/tmp/hermes-agent-pr /Users/ansel/.hermes/hermes-agent/venv/bin/python -m pytest tests/agent/test_auxiliary_named_custom_providers.py tests/agent/test_auxiliary_client.py::TestNormalizeAuxProvider tests/agent/test_auxiliary_client.py::TestTryPaymentFallback -q
# 35 passed

PYTHONPATH=/private/tmp/hermes-agent-pr /Users/ansel/.hermes/hermes-agent/venv/bin/python -m pytest tests/agent/test_auxiliary_client.py -q
# 110 passed

git diff --check

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

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

For New Skills

N/A.

Screenshots / Logs

N/A. This is provider-resolution logic covered by unit tests.

@zhonghui5207 zhonghui5207 force-pushed the codex/fix-custom-codex-alias branch from f1466a4 to f9aecc7 Compare April 29, 2026 15:02
@zhonghui5207 zhonghui5207 changed the title fix auxiliary custom codex provider alias fix(agent): preserve custom codex provider aliases Apr 29, 2026
@zhonghui5207 zhonghui5207 force-pushed the codex/fix-custom-codex-alias branch from f9aecc7 to 6749a45 Compare April 29, 2026 15:03
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder area/config Config system, migrations, profiles labels Apr 29, 2026
@zhonghui5207 zhonghui5207 marked this pull request as ready for review April 29, 2026 15:21
@teknium1

Copy link
Copy Markdown
Contributor

This looks implemented on current main by a broader alias-shadowing fix.

Automated hermes-sweeper review evidence:

  • agent/auxiliary_client.py:3383 preserves the raw requested provider before alias normalization.
  • agent/auxiliary_client.py:3646 tries named custom-provider lookup with that raw name before falling back to the normalized provider.
  • hermes_cli/runtime_provider.py:504-516 allows custom providers to shadow built-in aliases while still preventing accidental shadowing of canonical built-ins.
  • plugins/model-providers/openai-codex/__init__.py:8 declares codex as an alias for openai-codex, so the generic alias-shadowing fix covers this PR's custom codex case.
  • The behavior was added in 0ddc8aba6826c316060ff72f571f14bbba7058a8 (fix(fallback): let custom_providers shadow built-in aliases) with regression coverage in tests/agent/test_auxiliary_named_custom_providers.py.

Thanks for the original report and fix direction; the landed version moved the behavior into the shared provider-resolution path so other alias collisions inherit it too.

@teknium1 teknium1 closed this Jun 10, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

custom provider named codex is rewritten to openai-codex in auxiliary paths

3 participants