Skip to content

Commit 78bb4dc

Browse files
committed
🤖 fix: respect HTTP_PROXY env vars for network requests
Switch from undici Agent to EnvHttpProxyAgent to automatically respect HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables. This enables debugging/inspection via proxy tools like mitmproxy and supports corporate network environments that require proxying. The EnvHttpProxyAgent inherits all the same timeout configuration (bodyTimeout: 0, headersTimeout: 0) to prevent BodyTimeoutError on long-running reasoning model pauses. _Generated with mux_
1 parent 30b1c08 commit 78bb4dc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/node/services/aiService.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ import type {
4444
} from "@/common/types/stream";
4545
import { applyToolPolicy, type ToolPolicy } from "@/common/utils/tools/toolPolicy";
4646
import { MockScenarioPlayer } from "./mock/mockScenarioPlayer";
47-
import { Agent } from "undici";
47+
import { EnvHttpProxyAgent } from "undici";
4848

4949
// Export a standalone version of getToolsForModel for use in backend
5050

5151
// Create undici agent with unlimited timeouts for AI streaming requests.
5252
// Safe because users control cancellation via AbortSignal from the UI.
53-
const unlimitedTimeoutAgent = new Agent({
53+
// Uses EnvHttpProxyAgent to automatically respect HTTP_PROXY, HTTPS_PROXY,
54+
// and NO_PROXY environment variables for debugging/corporate network support.
55+
const unlimitedTimeoutAgent = new EnvHttpProxyAgent({
5456
bodyTimeout: 0, // No timeout - prevents BodyTimeoutError on long reasoning pauses
5557
headersTimeout: 0, // No timeout for headers
5658
});

0 commit comments

Comments
 (0)