Make WebFetch tool use GEMINI_SANDBOX_PROXY_COMMAND proxy when set #558
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.
TLDR
Currently, on macOS when
GEMINI_SANDBOX_PROXY_COMMANDis set, the WebFetch tool does not utilize that proxy. This PR fixes that by making the WebFetch tool use the sandbox proxy when it's configured via theGEMINI_SANDBOX_PROXY_COMMANDenvironment variable.Changes Made:
WebFetch Tool (
packages/core/src/tools/web-fetch.ts)GEMINI_SANDBOX_PROXY_COMMANDenvironment variablehttp://localhost:8877as the proxyDocumentation Updates
docs/tools/web-fetch.mdto document the new proxy supportTechnical Details:
GEMINI_SANDBOX_PROXY_COMMANDis setGEMINI_SANDBOX_PROXY_COMMAND, listens onhttp://localhost:8877by defaultBackward Compatibility:
config.getProxy()are preserved and take precedenceGEMINI_SANDBOX_PROXY_COMMANDenvironment variable set continue to work as beforeThe changes have been tested with
npm linkand a custom proxy script, and they work correctly.Reviewer Test Plan
This only applies to macOS (Seatbelt sandbox).
Run a proxy file with
GEMINI_SANDBOX_PROXY_COMMAND, for instance save something like this as~/.qwen/proxy.js:Have a file ~/.qwen/proxy.sh:
Then
npm run build && npm link.Then launch qwen like this:
GEMINI_SANDBOX_PROXY_COMMAND=~/.qwen/proxy.sh qwen -sAsk qwen to use tool web_fetch on bing, wikipedia, google, baidu.
The log file
~/var/opt/log/qwen_sandbox_proxy.logwill show something like:Testing Matrix
Linked issues / bugs
Resolves #556.