fix(agent): normalize socks:// env proxies for httpx/anthropic#13465
Closed
UNLINEARITY wants to merge 1 commit intoNousResearch:mainfrom
Closed
fix(agent): normalize socks:// env proxies for httpx/anthropic#13465UNLINEARITY wants to merge 1 commit intoNousResearch:mainfrom
UNLINEARITY wants to merge 1 commit intoNousResearch:mainfrom
Conversation
WSL2 / Clash-style setups often export ALL_PROXY=socks://127.0.0.1:PORT. httpx and the Anthropic SDK reject that alias and expect socks5://, so agent startup failed early with "Unknown scheme for proxy URL" before any provider request could proceed. Add shared normalize_proxy_url()/normalize_proxy_env_vars() helpers in utils.py and route all proxy entry points through them: - run_agent._get_proxy_from_env - agent.auxiliary_client._validate_proxy_env_urls - agent.anthropic_adapter.build_anthropic_client - gateway.platforms.base.resolve_proxy_url Regression coverage: - run_agent proxy env resolution - auxiliary proxy env normalization - gateway proxy URL resolution Verified with: PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 /home/nonlinear/.hermes/hermes-agent/venv/bin/pytest -o addopts='' -p pytest_asyncio.plugin tests/run_agent/test_create_openai_client_proxy_env.py tests/agent/test_proxy_and_url_validation.py tests/gateway/test_proxy_mode.py 39 passed.
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.
WSL2 / Clash-style setups often export ALL_PROXY=socks://127.0.0.1:PORT. httpx and the Anthropic SDK reject that alias and expect socks5://, so agent startup failed early with "Unknown scheme for proxy URL" before any provider request could proceed.
What does this PR do?
Normalizes
socks://...proxy environment variables tosocks5://...before Hermes hands them tohttpxor the Anthropic SDK.This fixes startup failures in WSL2 / Clash-style environments where
ALL_PROXYis commonly exported assocks://127.0.0.1:<port>/.httpxrejects that alias with
Unknown scheme for proxy URL, which caused Hermes tofail during client initialization before any provider request could proceed.
The fix is centralized in shared proxy normalization helpers and then applied
to the main agent, auxiliary client validation, Anthropic client
initialization, and gateway proxy resolution so the same environment behaves
consistently across those paths.
Type of Change
Changes Made
utils.py:normalize_proxy_url()normalize_proxy_env_vars()run_agent.pyso_get_proxy_from_env()normalizessocks://...to
socks5://...before handing proxy URLs tohttpxagent/auxiliary_client.pyso proxy environment variables arenormalized before validation
agent/anthropic_adapter.pyso Anthropic client initializationnormalizes proxy env vars before constructing the SDK client
gateway/platforms/base.pyso gateway proxy resolution alsonormalizes
socks://...proxy URLstests/run_agent/test_create_openai_client_proxy_env.pytests/agent/test_proxy_and_url_validation.pytests/gateway/test_proxy_mode.pyHow to Test
export ALL_PROXY=socks://127.0.0.1:3067/and confirm it no longer raises:
Unknown scheme for proxy URL URL('socks://127.0.0.1:3067/')PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 /home/nonlinear/.hermes/hermes-agent/ venv/bin/pytest -o addopts='' -p pytest_asyncio. plugin tests/run_agent/ test_create_openai_client_proxy_env. py tests/agent/ test_proxy_and_url_validation. py tests/gateway/test_proxy_mode. pyand confirm the targeted regression suite passes (
39 passed)Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
hermes --toolsets skills -q "Use the X skill to do Y"Screenshots / Logs
Bug
Fix