Skip to content

Sandbox does not forward GOOGLE_GENAI_API_VERSION into container #24828

Description

@rwalle

What happened?

When GEMINI_SANDBOX=true is set and GOOGLE_GENAI_API_VERSION is used alongside GOOGLE_GEMINI_BASE_URL to construct a Vertex-compatible API path, the sandbox fails with:

ModelNotFoundError: Not found (404)

sandbox.ts explicitly forwards a hardcoded list of environment variables into the Docker container (e.g., GOOGLE_GEMINI_BASE_URL, GOOGLE_VERTEX_BASE_URL, GOOGLE_GENAI_USE_VERTEXAI). When support for GOOGLE_GENAI_API_VERSION was added in contentGenerator.ts, the corresponding update to sandbox.ts was missed. The variable is available outside the sandbox but silently dropped when entering it.

Without GOOGLE_GENAI_API_VERSION, a GOOGLE_GEMINI_BASE_URL that depends on the API version segment to form a complete URL becomes invalid, and the API returns a 404.

Example

export GOOGLE_GEMINI_BASE_URL="https://my-gateway/vertex/"
export GOOGLE_GENAI_API_VERSION="v1beta1/projects/my-project/locations/global/publishers/google"
export GEMINI_SANDBOX=true
gemini -p "hello"
# => ModelNotFoundError: Not found (404)

Unsetting GEMINI_SANDBOX makes it work.

What did you expect to happen?

GOOGLE_GENAI_API_VERSION should be forwarded into the sandbox container like the other GOOGLE_* environment variables, so that custom Vertex-compatible base URLs work correctly in sandbox mode.

Client information

Client Information

Run gemini to enter the interactive CLI, then run the /about command.

> /about


│ About Gemini CLI                                                             │
│                                                                              │
│ CLI Version                0.32.1                                            │
│ Git Commit                 4d9d0b3                                           │
│ Model                      Auto (Gemini 3)                                   │
│ Sandbox                    sandbox-0.32.1-0                                  │
│ OS                         linux                                             │
│                                    

Login information

API key

Anything else we need to know?

The environment variable was introduced in #16177 to address #16173, however a small change in sandbox.ts is missing.

Fix:
Add GOOGLE_GENAI_API_VERSION to the forwarded env vars in packages/cli/src/utils/sandbox.ts, in both the Docker path (~line 516) and the LXC envVarsToForward record (~line 957).

I have a fix in my fork but am unable to open a pull request due to the CLA requirement and some build issue. Anyone interested in submitting the PR is welcome to take the change from my commit:
d00e8b5


Workaround

Callers can use the SANDBOX_ENV escape hatch to forward the variable manually (e.g., SANDBOX_ENV=GOOGLE_GENAI_API_VERSION=<value>). This is not ideal because it requires every caller to know about this sandbox implementation detail and shifts the burden of working around an upstream bug to downstream consumers.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions