-
Notifications
You must be signed in to change notification settings - Fork 52.4k
fix(codex): respect HERMES_CODEX_BASE_URL in all paths #40924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+70
β13
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| """Tests for resolve_codex_base_url() β centralized Codex base URL resolution. | ||
|
|
||
| Ensures HERMES_CODEX_BASE_URL env var takes priority over pool entry | ||
| base_url and DEFAULT_CODEX_BASE_URL across all code paths. | ||
|
|
||
| Regression test for: https://github.com/NousResearch/hermes-agent/issues/5875 | ||
| """ | ||
|
|
||
| import os | ||
| from unittest import mock | ||
|
|
||
| from hermes_cli.auth import DEFAULT_CODEX_BASE_URL, resolve_codex_base_url | ||
|
|
||
|
|
||
| class TestResolveCodexBaseUrl: | ||
| """resolve_codex_base_url(pool_base_url=None) priority chain.""" | ||
|
|
||
| def test_default_when_no_override(self): | ||
| with mock.patch.dict(os.environ, {}, clear=True): | ||
| assert resolve_codex_base_url() == DEFAULT_CODEX_BASE_URL | ||
|
|
||
| def test_env_var_takes_priority_over_default(self): | ||
| with mock.patch.dict(os.environ, {"HERMES_CODEX_BASE_URL": "http://localhost:8787/v1"}): | ||
| assert resolve_codex_base_url() == "http://localhost:8787/v1" | ||
|
|
||
| def test_env_var_takes_priority_over_pool(self): | ||
| with mock.patch.dict(os.environ, {"HERMES_CODEX_BASE_URL": "http://localhost:8787/v1"}): | ||
| result = resolve_codex_base_url(pool_base_url="https://chatgpt.com/backend-api/codex") | ||
| assert result == "http://localhost:8787/v1" | ||
|
|
||
| def test_pool_base_url_used_when_no_env(self): | ||
| with mock.patch.dict(os.environ, {}, clear=True): | ||
| result = resolve_codex_base_url(pool_base_url="https://custom-proxy.example.com/v1") | ||
| assert result == "https://custom-proxy.example.com/v1" | ||
|
|
||
| def test_env_var_stripped_and_rstripped(self): | ||
| with mock.patch.dict(os.environ, {"HERMES_CODEX_BASE_URL": " http://localhost:8787/v1/ "}): | ||
| assert resolve_codex_base_url() == "http://localhost:8787/v1" | ||
|
|
||
| def test_empty_env_var_falls_through(self): | ||
| with mock.patch.dict(os.environ, {"HERMES_CODEX_BASE_URL": " "}): | ||
| assert resolve_codex_base_url() == DEFAULT_CODEX_BASE_URL | ||
|
|
||
| def test_empty_pool_base_url_falls_through(self): | ||
| with mock.patch.dict(os.environ, {}, clear=True): | ||
| assert resolve_codex_base_url(pool_base_url="") == DEFAULT_CODEX_BASE_URL | ||
| assert resolve_codex_base_url(pool_base_url=None) == DEFAULT_CODEX_BASE_URL |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This applies the environment override, but
resolve_codex_base_url(base_url)cannot honormodel.base_urlbecause it receives no model configuration. Please add the matching-provider config fallback for an empty/default pool URL (while preserving a non-default pool endpoint), as the PR description and #60198 discussion require.