Fix custom provider API mode detection for OpenAI-compatible endpoints - #9155
Open
luoxiao6645 wants to merge 1 commit into
Open
Fix custom provider API mode detection for OpenAI-compatible endpoints#9155luoxiao6645 wants to merge 1 commit into
luoxiao6645 wants to merge 1 commit into
Conversation
luoxiao6645
force-pushed
the
fix/custom-provider-openai-messages-9064
branch
from
April 17, 2026 10:07
f2c0741 to
d124690
Compare
teknium1
reviewed
Jul 12, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the detailed cross-path analysis. The linked plain-custom failure is already covered on current main by 0e4c879a3 (hermes_cli/runtime_provider.py:136-155), but there is still a narrow hostname-hardening gap worth salvaging.
Problems
hermes_cli/providers.py:551still uses a broad"api.openai.com" in url_lowercheck for known providers. This reaches live model-switch setup throughagent/agent_runtime_helpers.py:1752-1756.- The added proxy test uses
"totally-unknown", so it exercises the already hostname-safe unknown-provider branch (hermes_cli/providers.py:559-568), not the known-provider branch this PR changes. - Current main already centralizes hostname parsing in
utils.base_url_hostname()(hermes_cli/runtime_provider.py:117); the PR's duplicated local helpers should not be carried forward.
Suggested changes
- Salvage the remaining
providers.pybranch withbase_url_hostname(base_url) == "api.openai.com". - Add the regression using a known provider and a proxy path containing
api.openai.com.
Automated hermes-sweeper review.
| result = determine_api_mode("deepseek") | ||
| assert result == "chat_completions" | ||
|
|
||
| def test_proxy_path_containing_openai_does_not_force_responses(self): |
Contributor
There was a problem hiding this comment.
This uses an unknown provider, which already takes the hostname-safe fallback branch. Please exercise a known provider (for example openrouter) so the test covers the get_provider(provider) is not None branch that still has the substring check on current main.
This was referenced Aug 3, 2026
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
Fixes #9064
Problem
Custom OpenAI-compatible endpoints could be misclassified as codex_responses instead of chat_completions.
That caused Hermes to send Responses-style payloads to chat-completions backends, which broke request validation and produced errors such as:
Key: 'GptVParam.Messages' Error:Field validation for 'Messages' failed on the 'required' tag
Fix
Regression Coverage
Validation
venv\Scripts\python -m pytest -n 0 tests\agent\test_auxiliary_client.py
venv\Scripts\python -m pytest -n 0 tests\hermes_cli\test_runtime_provider_resolution.py
venv\Scripts\python -m pytest -n 0 tests\run_agent\test_strict_api_validation.py
venv\Scripts\python -m pytest -n 0 tests\agent\test_minimax_provider.p