fix(agent): respect HTTP_PROXY/HTTPS_PROXY when using custom httpx transport#12540
Closed
heykb wants to merge 2 commits into
Closed
fix(agent): respect HTTP_PROXY/HTTPS_PROXY when using custom httpx transport#12540heykb wants to merge 2 commits into
heykb wants to merge 2 commits into
Conversation
…ansport When creating httpx.Client with a custom transport for TCP keepalive, proxy environment variables (HTTP_PROXY, HTTPS_PROXY) were ignored because httpx only auto-reads them when transport=None. Add _get_proxy_from_env() to explicitly read proxy settings and pass them to httpx.Client, ensuring providers like kimi-coding-cn work correctly when behind a proxy. Fixes connection errors when HTTP_PROXY/HTTPS_PROXY are set.
The kimi-k2.5 model requires temperature=1.0, not 0.6. The API returns: "invalid temperature: only 1 is allowed for this model" Move kimi-k2.5 from _KIMI_INSTANT_MODELS to _KIMI_THINKING_MODELS so it gets the correct fixed temperature of 1.0 instead of 0.6. Update tests and docstring to reflect the correct behavior.
Contributor
|
Merged the proxy fix via #12657 — your commit I left the kimi-k2.5 temperature contract change out of the salvage — it's a separate behavioral decision that needs its own triage against the Moonshot docs and the kimi-for-coding endpoint. Happy to look at that on its own if you want to open a follow-up PR for just those changes. The proxy portion fixes a Cloudflare 403 regression for users on proxy setups (WSL2 + Clash, corporate egress) that was introduced by #11277. |
This was referenced Apr 27, 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.
What does this PR do?
Fixes a bug where
HTTP_PROXY/HTTPS_PROXYenvironment variables were ignored when using the kimi-coding-cn provider (or any provider) behind a proxy.The root cause was that when creating
httpx.Clientwith a customHTTPTransport(for TCP keepalive), httpx only reads proxy settings from environment variables whentransport=None. Since we were explicitly passing a custom transport, the proxy settings were never applied.This fix adds
_get_proxy_from_env()to explicitly read proxy settings and pass them tohttpx.Client, ensuring providers work correctly when behind a proxy.Related Issue
Fixes connection errors like:
Type of Change
Changes Made
run_agent.py:_get_proxy_from_env()function to read proxy from environment variablesproxyparameterHow to Test
Set proxy environment variable:
export HTTPS_PROXY=http://your-proxy:8080Configure kimi-coding-cn provider:
hermes model # Select kimi-coding-cnRun a chat:
hermes chat -q "Hello"Before this fix: Connection error. After this fix: Request succeeds.
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
Technical Details
The issue is in httpx's Client initialization:
When a custom transport is provided,
allow_env_proxiesbecomesFalse, and httpx won't read proxy settings from environment variables. This fix explicitly reads and passes the proxy URL to ensure it's always used when configured.