Skip to content

fix(runtime_provider): honour transport field on v12+ providers dict#17901

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-efb63eb2
Apr 30, 2026
Merged

fix(runtime_provider): honour transport field on v12+ providers dict#17901
teknium1 merged 2 commits into
mainfrom
hermes/hermes-efb63eb2

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

v12+ providers: dict lookups now respect the transport: field, not only the legacy api_mode: spelling.

Salvage of #17860 by @zicochaos onto current main.

Root cause

migrate_config v11→v12 writes every custom provider's API mode under the new transport: field (per _normalize_custom_provider_entry's _KNOWN_KEYS). But _get_named_custom_provider short-circuits on the providers-dict before reaching get_compatible_custom_providers, reading only entry.get("api_mode") — so on every migrated config the lookup returns None for api_mode.

Downstream, _resolve_named_custom_runtime then falls back through _detect_api_mode_for_url(base_url) or "chat_completions". For loopback URLs (proxies, local servers) or unknown hostnames the URL detector returns None, silently downgrading configured codex_responses / anthropic_messages providers to chat_completions — routing requests to /v1/chat/completions instead of /v1/responses.

Changes

  • hermes_cli/runtime_provider.py: read entry.get("api_mode") or entry.get("transport") at both match branches (by-key and by-display-name). The runtime normaliser _normalize_custom_provider_entry already does this — the fix lifts the same compat into the direct-dict reader.
  • tests/hermes_cli/test_user_providers_model_switch.py: 3 regression tests covering transport-field read, legacy api_mode spelling, and display-name match branch.
  • scripts/release.py: AUTHOR_MAP entry for zicochaos.

Validation

Before After
v12 providers dict with transport: codex_responses on loopback URL downgraded to chat_completions preserved as codex_responses
legacy hand-edited api_mode: works works
match by display name ignored transport honors transport
  • targeted tests: scripts/run_tests.sh tests/hermes_cli/test_user_providers_model_switch.py → 25 passed
  • E2E: wrote a v12 config with transport: codex_responses pointing at http://127.0.0.1:4000/v1, resolve_runtime_provider(requested="my-codex-proxy") returned api_mode="codex_responses" (would be chat_completions without the fix)

Closes #17860

zicochaos and others added 2 commits April 30, 2026 03:27
…rt field on v12+ providers dict

The v11→v12 migrate_config step writes the API mode for every entry
under the new transport: field (per the v12+ schema in
_normalize_custom_provider_entry).  _get_named_custom_provider
read the legacy api_mode: spelling only, so for every migrated
config the lookup returned None for the api mode.

Downstream, _resolve_named_custom_runtime then falls back through
custom_provider.get("api_mode") or _detect_api_mode_for_url(base_url)
or "chat_completions".  For loopback URLs (proxies, local servers)
or unknown hostnames, the URL detector returns None and the resolver
silently downgrades the configured codex_responses /
anthropic_messages transport to chat_completions.  Requests
get sent to /v1/chat/completions instead of /v1/responses or
/v1/messages and the provider 404s — or worse, returns a usable
chat_completions response while skipping the model's reasoning /
caching surface.

Fix: read both field names — entry.get("api_mode") or
entry.get("transport") — at the two match-by-key + match-by-name
branches in _get_named_custom_provider.  The runtime normaliser
_normalize_custom_provider_entry already accepts both spellings;
this lifts the same compat into the direct-dict reader so v12+
configs work without going through the shim.

Adds three regression tests under
tests/hermes_cli/test_user_providers_model_switch.py:
- transport field is read on the match-by-key branch
- legacy api_mode spelling still works for hand-edited configs
- transport is read on the match-by-display-name branch
@teknium1 teknium1 merged commit 01d7c87 into main Apr 30, 2026
11 of 12 checks passed
@teknium1 teknium1 deleted the hermes/hermes-efb63eb2 branch April 30, 2026 10:29
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard area/config Config system, migrations, profiles labels Apr 30, 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/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants