Skip to content
This repository was archived by the owner on Sep 23, 2026. It is now read-only.

fix(net): honour system proxy env vars in aiohttp sessions - #2461

Open
logicwu0 wants to merge 1 commit into
MoonshotAI:mainfrom
logicwu0:fix/2455-fetchurl-proxy
Open

logicwu0 wants to merge 1 commit into
MoonshotAI:mainfrom
logicwu0:fix/2455-fetchurl-proxy

Conversation

@logicwu0

@logicwu0 logicwu0 commented Jun 18, 2026 •

Copy link
Copy Markdown

Problem

Behind a proxy, FetchURL (and WebSearch) fail to reach the network even though curl in the same environment works — with HTTP_PROXY/HTTPS_PROXY set, curl -I https://www.google.com returns 200 but FetchURL errors out. (Fixes #2455)

Root cause

All outbound HTTP goes through new_client_session() in kimi_cli/utils/aiohttp.py, which builds an aiohttp.ClientSession without trust_env=True. Unlike curl/httpx, aiohttp ignores HTTP_PROXY / HTTPS_PROXY / NO_PROXY (and .netrc) from the environment unless trust_env=True is set, so the proxy is never used.

Fix

Set trust_env=True in new_client_session(). Because every caller (FetchURL, WebSearch, auth, telemetry, …) goes through this single helper, this one change makes them all honour the system proxy.

Tests

Added test_session_trusts_env_for_proxy in tests/utils/test_aiohttp_timeout.py asserting session.trust_env is True.

uv run pytest tests/utils/test_aiohttp_timeout.py → 4 passed. ruff format/check clean.


Open in Devin Review

new_client_session() created aiohttp.ClientSession without trust_env=True, so
aiohttp ignored HTTP_PROXY/HTTPS_PROXY/NO_PROXY from the environment. Behind a
proxy, FetchURL/WebSearch (and every other caller of this helper) failed to
reach the network even though curl worked.

Set trust_env=True so all outbound requests honour the system proxy.

Fixes MoonshotAI#2455

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

This branch has not been deployed

No deployments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

1 participant