Repository navigation
feat: implement Gemini CLI as sandbox external agent (#2424) - #2535
Merged
Merged
Conversation
Adapter (buildExec + stream-json parser) for @google/gemini-cli 0.49.0 driven through the tale-gemini-run wrapper. Managed runs route via the gateway's Google GenAI-compatible /genai route (GOOGLE_GEMINI_BASE_URL + session VK as GEMINI_API_KEY); BYO uses GEMINI_API_KEY / Vertex vars with vendor-native model ids (catalog gemini entries gain nativeModelId). Managed runs deny the CLI's native google_web_search/web_fetch unless nativeWebTools; prompt + system-prompt append + settings ride stdin, never argv. Parser verified against a sanitized real 0.49.0 capture; zero-token runs emit no usage event.
Extend the agentKind unions (turn actions, lifecycle, serializable config, readiness, chat/editor UI) with 'gemini', label it in en/de/fr, and ship the built-in Gemini CLI composer agent (managed, Gemini 3 Pro/Flash via the OpenRouter catalog).
Install @google/[email protected] into /opt/agents and add the tale-gemini-run wrapper, which stages per-exec system settings (GEMINI_CLI_SYSTEM_SETTINGS_PATH) and the per-exec ~/.gemini context file carrying the system-prompt append, then pipes the prompt into the headless CLI. The image smoke test asserts the binaries and that every gemini flag the wrapper passes exists in the pinned CLI's --help.
yannickmonney
enabled auto-merge (squash)
July 7, 2026 06:04
This was referenced Jul 7, 2026
yannickmonney
added a commit
that referenced
this pull request
Jul 7, 2026
…leet The budget was set at 4400 MB when the image was ~4.0 GB; the six external agent CLIs added since (Cursor #2481, Hermes #2500, Gemini #2535, Codex #2536, Pi #2550, OpenClaw #2555) grew it to ~4.9 GB and none of those PRs updated the budget, so the Validate images gate is red on main too. Document the fleet as a named cost and restore the ~10% headroom convention at 5400.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
agentKind: geminias a first-class external sandbox runtime alongside Claude Code, Cursor, and Hermes Agent.buildExec+stream-jsonparser), thetale-gemini-runwrapper, sandbox image tooling (pinned@google/[email protected]), a built-in chat composer entry, and docs/i18n (en/de/fr).GOOGLE_GEMINI_BASE_URL=<gateway>/genai+ the session virtual key asGEMINI_API_KEY, with the auth type pinned togemini-api-keyvia a per-exec system settings file (with the base-URL env set alone, the CLI's env inference selects itsgatewayauth type, which headless auth validation rejects at 0.49.0 — verified against the real CLI). Models are the catalog gateway ids (openrouter/google/gemini-3.1-pro-preview; Bifrost's/genai{model:*}matcher takes slashed ids — verified live against the pinned CLI and Bifrost v1.5.13 sources).GEMINI_API_KEY(orGOOGLE_API_KEY+GOOGLE_GENAI_USE_VERTEXAIfor Vertex). Shipped catalog-shaped refs translate to Google-native ids via newnativeModelIdentries on the catalog's Gemini models (byoModelIdSource: 'vendor-native').google_web_search/web_fetchviatools.excludeunlessnativeWebTools: true(the interactiveask_usertool is force-excluded by the CLI itself in headless mode); Playwright MCP + the integrations dispatch bridge ride the settingsmcpServersmap, with the session key referenced as${TALE_GATEWAY_TOKEN}env interpolation so it never appears in the staged settings file.~/.gemini/tale-context-<uuid>.mdadded tocontext.fileNamealongsideGEMINI.md(append semantics;GEMINI_SYSTEM_MDwould replace the core prompt) and cleaned up after the run; delivery to the model request was verified end-to-end against a mock GenAI gateway.--resume <uuid>(verified working headless at 0.49.0); the parser carries theinitevent'ssession_idonto the result. Usage comes from theresultevent'sstats(real token counts); zero-token runs emit no usage event.Reached max session turnsmaps to themax-turnsresult status.fallbackModelis deliberately ignored (no availability-fallback chain) and the docs make no fallback claim.fixtures/gemini/shell-turn.jsonlis a sanitized capture of a REAL 0.49.0 headless turn (including a realrun_shell_commandround trip) recorded against a local mock GenAI gateway;record-fixture.mddocuments the recipe.All shared-file edits are strictly additive (union widenings + new blocks) so the concurrent Codex (#2422) merge stays mechanical.
Closes #2424
Test plan
vitest --project server lib/agent-adapters(98 tests, includes the real-capture Gemini fixture + chunked parses)vitest --project server --project pii(703 files, 74 858 tests)tsc --noEmit,oxlint --type-aware,oxfmt --check,ruff format/check(wrapper),knip,migrations:check(schema/config snapshots: data-safe, no migration needed)--resume <uuid>,tools.excluderemoving web tools from the request, system-prompt append reaching the request body, wrapper end-to-end (exit codes, staging + cleanup)