docs(self-hosted): E2B guide stops the worker after 5 minutes and exposes the environment key
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Idoneità per principianti
- 85/100
- Tipo di issue
- Documentazione
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- bash, markdown
- Ambito
- documentation
Direzione di ricerca
Il file da modificare è docs/self-hosted/providers/e2b/README.md; l'issue include un README proposto completo da copiare o adattare. Leggi la guida esistente del provider Vercel per il pattern della nota su timeout/limite di piano, poi aggiorna la quick start di E2B, la variante interattiva, la sezione di gestione delle chiavi e la pulizia come proposto. Fatto significa che la guida corrisponde ai passaggi testati: --timeout 3600, la chiave catturata tramite jq senza stamparla, il log del worker controllato per polling, e la pulizia che elimina sia la sandbox sia l'ambiente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hi, I work on integrations at E2B. Thanks for adding an E2B guide to the self-hosted docs. We ran docs/self-hosted/providers/e2b/README.md end to end on E2B production with gemini-api 0.4.6, @e2b/cli 2.21.0, and both antigravity-preview-05-2026 and antigravity-preview-09-2026. The quick start works, but four things break for real sessions:
- The worker stops after 5 minutes.
e2b sandbox create --detach basehas no--timeout, so the microVM gets the 5-minute default and the worker stops with it. The worker only makes outbound calls, so its polling does not extend the timeout. After that,gemini-api agent runhangs with no output or error. - The agent can read the environment key. The worker and the agent's
execute_bashrun as the same user in the same microVM, so a key passed in with-e GEMINI_ENVIRONMENT_KEYis readable from/proc/<worker-pid>/environ. We confirmed this by asking the agent to count matches there. The interactive variant also puts the key on the command line, wherepsshows it. - Cleanup leaves the environment behind. It kills the microVM but never deletes the
self_hostedenvironment. - No way to see the worker started.
exec -bdrops its output, so a failed connect looks the same as a working one.
Proposed README below, in the same 3-step shape as the other providers. Changes:
--timeout 3600on bothcreatecommands, plus a note on the default and plan limits (same pattern as the Vercel guide).- The environment response goes straight into variables with
jq, so the one-time key is never printed. - The worker logs to
/tmp/worker.log, with a one-line check that it is polling. - A short section on keeping the key away from the agent, pointing to E2B Secrets and our Gemini Managed Agents guide for the full setup (prebuilt
gemini-e2btemplate, keys injected outside the sandbox, web workbench). - Cleanup also runs
gemini-api environments delete. - The interactive variant drops
--environment-key=(already exported) and says to run the interaction from a second terminal.
We ran the proposed version verbatim: the worker logged polling, the agent answered and wrote hello.txt inside the microVM, a second interaction 5.5 minutes in (past the old 5-minute cutoff) still worked, and cleanup removed both the microVM and the environment. Since the repo doesn't take outside PRs, here is the full text to copy or change however you like.
Proposed docs/self-hosted/providers/e2b/README.md
# E2B
Run the Gemini API self-hosted environment runtime inside an
[E2B](https://e2b.dev/) Firecracker microVM using the `e2b` CLI.
## Prerequisites
Install the [`gemini-api` CLI](https://github.com/google-gemini/gemini-api-cli)
and [Gemini API key](https://ai.google.dev/gemini-api/docs/api-key) on your
local machine, plus `jq` and the `e2b` CLI:
```bash
npm install -g @e2b/cli
e2b auth login
```
Create a `self_hosted` environment and export both `GEMINI_ENVIRONMENT_ID` and
`GEMINI_ENVIRONMENT_KEY` (`environment_key` is returned **only once at creation
time**, so it goes straight into a variable instead of your terminal):
```bash
export GEMINI_API_KEY="your-api-key"
RESP=$(curl -fsSL -X POST \
"https://generativelanguage.googleapis.com/v1beta/environments" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"mode": "self_hosted"}')
export GEMINI_ENVIRONMENT_ID=$(jq -r .id <<<"$RESP") # no "environments/" prefix
export GEMINI_ENVIRONMENT_KEY=$(jq -r .environment_key <<<"$RESP")
unset RESP
```
## Quick Start
```bash
# 1. Create a detached E2B microVM (use --timeout 3600 on Hobby)
SANDBOX_ID=$(e2b sandbox create --detach --timeout 3600 base)
# 2. Install the gemini-api CLI inside the microVM
e2b sandbox exec "$SANDBOX_ID" bash -c \
"curl -fsSL https://raw.githubusercontent.com/google-gemini/gemini-api-cli/main/scripts/install.sh \
| bash"
# 3. Connect the microVM to your Gemini API environment
e2b sandbox exec -b -e GEMINI_ENVIRONMENT_KEY="$GEMINI_ENVIRONMENT_KEY" \
"$SANDBOX_ID" bash -c \
'PATH="$HOME/.local/bin:$PATH" gemini-api environments connect > /tmp/worker.log 2>&1'
```
Check that the worker is up. The log should end with `polling`:
```bash
e2b sandbox exec "$SANDBOX_ID" cat /tmp/worker.log
```
> [!NOTE]
>
> The microVM timeout defaults to **5 minutes** when `--timeout` is omitted,
> and the worker stops with the microVM. The worker only makes outbound calls,
> so its polling does not extend the timeout. **Hobby** supports up to
> **1 hour** (`--timeout 3600`), **Pro** up to **24 hours** (`--timeout 86400`).
Or run interactively inside the microVM terminal (exporting
`GEMINI_ENVIRONMENT_KEY` inside the microVM shell):
```bash
e2b sandbox create --timeout 3600 base
# Inside the microVM shell:
export GEMINI_ENVIRONMENT_KEY="..."
curl -fsSL https://raw.githubusercontent.com/google-gemini/gemini-api-cli/main/scripts/install.sh \
| bash
PATH="$HOME/.local/bin:$PATH" gemini-api environments connect
```
The worker holds this terminal, so run the interaction below from a second
terminal on your local machine.
## Run an Interaction
```bash
gemini-api agent run \
"Create hello.txt and run uname -a in bash." \
--agent antigravity-preview-05-2026 \
--body "{\"environment\": \"$GEMINI_ENVIRONMENT_ID\"}"
```
## Keep the environment key away from the agent
The worker and the agent's `execute_bash` tool run as the same user in the same
microVM, so a key passed in with `-e` can be read by the agent from
`/proc/<worker-pid>/environ`. For anything beyond a test, keep both keys in
[E2B Secrets](https://docs.e2b.dev/secrets/inject) and let E2B add them to
requests to the Gemini API, so the worker only ever sees a placeholder. E2B's
[Gemini Managed Agents guide](https://docs.e2b.dev/agents/gemini-managed-agents)
covers that setup with the prebuilt `gemini-e2b` template, which also serves a
web workbench for chatting with the agent.
## Cleanup
```bash
e2b sandbox kill "$SANDBOX_ID"
gemini-api environments delete "$GEMINI_ENVIRONMENT_ID"
```
- Lingua principale
- Go
- Stelle
- 514
- Fork
- 84
- Merge medio
- 1g 15h
- PR unite (30g)
- 69
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di google-gemini/gemini-api-cli
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
google-gemini/gemini-api-cli#231 · 5 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
google-gemini/gemini-api-cli#221 ·
I maintainer di solito rispondono entro 1 giorno
-
..Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
google-gemini/gemini-api-cli#205 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 25/100
google-gemini/gemini-api-cli#188 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
google-gemini/gemini-api-cli#176 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di google-gemini/gemini-api-cli
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
google/osv-scanner#3327 ·
I maintainer di solito rispondono entro 1 giorno
-
tld-snapshot
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
awslabs/ferret-scan#1064 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
VictoriaMetrics/VictoriaTraces#335 ·
I maintainer di solito rispondono entro 1 giorno
-
【文档错误】创建镜像空间步骤中的截图标注与文字描述不一致Apertaenhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
DaoCloud/DaoCloud-docs#7839 ·
I maintainer di solito rispondono entro 1 giorno