Skip to content

Bug: "HttpsProxyAgent is not a constructor" crash when using Vertex AI with HTTP_PROXY environment variables #26533

@Xuepoo

Description

@Xuepoo

What happened?

When running Gemini CLI using Vertex AI authentication, having standard proxy environment variables (HTTP_PROXY/HTTPS_PROXY) exported in the shell causes a fatal crash during the authentication phase.

Error Output:
TypeError: HttpsProxyAgent is not a constructor

Root Cause Analysis:
The @google-cloud/vertexai or google-auth-library relies on gaxios. When proxy env vars are present, gaxios dynamically attempts to instantiate https-proxy-agent. Due to bundling issues (likely CommonJS vs ESM export mismatch during the esbuild/webpack process of the gemini-cli bundle), the exported agent is an object rather than a constructor class.

Reproduction:

  1. Configure Gemini CLI to use Vertex AI auth.
  2. export HTTPS_PROXY=http://127.0.0.1:7897
  3. Run any prompt in the CLI.

Workaround:
Clearing the proxy env vars and using an OS-level TUN interface works perfectly, proving the issue is strictly isolated to the proxy agent instantiation path in the bundled JS chunk.

Image

What did you expect to happen?

The CLI should successfully instantiate the proxy agent and route the Vertex AI requests through the local proxy without crashing.

Client information

  • CLI Version: 0.40.1
  • Git Commit: 7a382e0
  • Session ID: 7c5a9b2f-e017-4a8d-9465-ca7e748930cb
  • Operating System: linux v25.9.0
  • Sandbox Environment: no sandbox
  • Model Version: gemini-3.1-pro-preview
  • Auth Type: vertex-ai
  • Memory Usage: 908.4 MB
  • Terminal Name: ghostty 1.3.1-arch2.2
  • Terminal Background: #121212
  • Kitty Keyboard Protocol: Supported

Login information

No response

Anything else we need to know?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    status/need-triageIssues that need to be triaged by the triage automation.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions