fix(runtime_provider): _get_named_custom_provider must honour transport field on v12+ providers dict#17860
Closed
zicochaos wants to merge 1 commit into
Closed
Conversation
…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
Contributor
|
Merged via PR #17901 onto current main. Your fix commit was rebase-merged so your authorship is preserved in git log — thanks for the tight, well-scoped diagnosis and regression tests! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The v11→v12
migrate_configstep writes the API mode for every entry under the newtransport:field (per the v12+ schema in_normalize_custom_provider_entry's_KNOWN_KEYS)._get_named_custom_providerreads only the legacyapi_mode:spelling, so for every migrated config the lookup returns None.Downstream,
_resolve_named_custom_runtimethen falls back throughcustom_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 configuredcodex_responses/anthropic_messagestransport tochat_completions.Result: a config like
routes requests to
/v1/chat/completionsinstead of/v1/responses. The proxy returns 404 (if it's strict) or strips out reasoning/caching surface (if it's lenient).End-to-end repro
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_entryalready accepts both spellings (line 2358); this lifts the same compat into the direct-dict reader so v12+ configs work without going through the shim.Test plan
tests/hermes_cli/test_user_providers_model_switch.py::test_get_named_custom_provider_reads_transport_field— transport field is read on the match-by-key branchtests/hermes_cli/test_user_providers_model_switch.py::test_get_named_custom_provider_legacy_api_mode_field_still_works— legacyapi_mode:spelling still works for hand-edited configstests/hermes_cli/test_user_providers_model_switch.py::test_get_named_custom_provider_transport_resolves_via_display_name— transport is read on the match-by-display-name branchRelated
Companion to PR #17844 — same v11→v12 migration boundary, different downstream loss. Once both land,
hermes config migrateproduces a config that's faithfully read by every code path.