Skip to content

feat(eval): add Gemini CLI agent harness - #57

Draft
Rodriguespn wants to merge 6 commits into
mainfrom
pedrorodrigues/add-gemini-cli-agent-support
Draft

feat(eval): add Gemini CLI agent harness#57
Rodriguespn wants to merge 6 commits into
mainfrom
pedrorodrigues/add-gemini-cli-agent-support

Conversation

@Rodriguespn

@Rodriguespn Rodriguespn commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Adds gemini-cli (Google's Gemini CLI) as an eval agent alongside claude-code and codex, built on the same per-agent framework (packages/core/src/agents/<name>/): a runner + a parser + a registry entry + a factory + an experiment. Orchestration is unchanged and the transcript is parsed back into the same surface scorers already use. Runs in both modes (tools + local-stack), like Claude Code and Codex.

gemini-cli runs headless via gemini --approval-mode yolo --output-format stream-json (CLI pinned to 0.46.0) in a Docker sandbox, with the prompt fed on stdin.

  • Trusted-folder gate — sets GEMINI_CLI_TRUST_WORKSPACE=true. Since 0.46 gemini refuses to run headless in an "untrusted" folder (and silently downgrades --approval-mode yolo to prompt-for-approval), which would fail/hang every sandbox run. The env var is ignored by versions that lack it.
  • MCP servers are written to $HOME/.gemini/settings.json (outside the scored workspace).
  • Stop reason comes from the terminal result.status. Streamed assistant delta chunks are merged into one message so step count / report stay correct.
  • Skill-activation tracking — SKILL.md reads are surfaced via the shared extractor (loadedSkill), the same way as claude-code / codex.
  • Reasoning effort (display-only) — gemini-cli has no flag to set effort; gemini-3.1-pro-preview thinks at high by default (inherited from chat-base-3). The factory records reasoningEffort: "high" in the experiment metadata for benchmark parity with the other high-effort agents (Opus 4.8), but does not pass it to the CLI.

Closes AI-862

@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
evals Ignored Ignored Preview Jul 2, 2026 11:12pm

Request Review

@Rodriguespn Rodriguespn added the run-evals Add to a PR to refresh benchmark evals label Jun 24, 2026
@Rodriguespn Rodriguespn removed the run-evals Add to a PR to refresh benchmark evals label Jun 24, 2026
@Rodriguespn
Rodriguespn force-pushed the pedrorodrigues/add-gemini-cli-agent-support branch from e2c8a92 to e0f4b2e Compare July 2, 2026 00:17
@linear-code

linear-code Bot commented Jul 2, 2026

Copy link
Copy Markdown
AI-862 Add Gemini CLI agent support to the eval framework

Add a gemini-cli agent option (geminiCliAgent() AgentHarness in packages/core/src/index.ts) that shells out to Google's Gemini CLI (@google/gemini-cli), alongside the existing ai-sdk agent — mirroring codexAgent() (AI-849).

The Gemini CLI runs headless via gemini <msg> --approval-mode yolo --output-format stream-json (auth via GEMINI_API_KEY), in both eval modes (local-stack and tools/MCP) like Claude Code / Codex. Unlike opencode's direct Google provider — which drops the turn after a tool call — gemini-cli carries the tool-use loop through to a final answer, so it's the working path for direct Gemini.

Shipped as a runner + parser + registry entry + factory + experiments (gemini-cli-3.5-flash, gemini-cli-3.1-pro), both verified e2e against a tools-mode eval.

Rate limits

We will likely need a way around the Gemini models' rate limits. The Google AI Studio / Gemini API tiers impose aggressive per-minute and per-day request/token limits, and the refresh matrix (many evals × attempts, run concurrently) will hit them — surfacing as 429s that look like agent failures rather than genuine task failures. Options to consider:

  • A paid / higher-tier GEMINI_API_KEY (or routing through Vertex AI).
  • Throttling + exponential backoff & retry on 429 in the harness (distinct from error_max_turns).
  • Lower concurrency for gemini-cli experiments in the eval-refresh workflow.
  • Treating rate-limited runs as "errored" (not scored 0/N) so they don't pollute pass-rates.

@Rodriguespn
Rodriguespn force-pushed the pedrorodrigues/add-gemini-cli-agent-support branch from e0f4b2e to 1b6b730 Compare July 2, 2026 00:28
@Rodriguespn Rodriguespn added the run-evals Add to a PR to refresh benchmark evals label Jul 2, 2026
@Rodriguespn
Rodriguespn marked this pull request as ready for review July 2, 2026 00:58
@Rodriguespn
Rodriguespn requested a review from mattrossman July 2, 2026 00:58
Rodriguespn and others added 3 commits July 2, 2026 14:33
Rebuild the Gemini CLI agent on the current agents/<name>/ architecture
(runner + parser + index), mirroring the Claude Code and Codex harnesses:

- packages/core/src/agents/gemini-cli/{runner,parser,index,parser.test}.ts
- Register geminiCliDefinition and route gemini-cli -> "google" provider
- Add "gemini-cli" / "google" to the agent + provider enums, export
  geminiCliAgent, and render both in the web UI (label + Gemini model formatter)
- Prompt is fed on stdin (like Codex), not a positional arg — avoids the
  ARG_MAX / shell-expansion surface
- Skill-activation tracking wired via the shared extractor, same as the others
- experiments/gemini-cli-3.5-flash.ts + gemini-cli-3.1-pro.ts (suite: benchmark;
  auto-discovered by CI), GEMINI_API_KEY wired into eval-refresh + .env.example
- Add @ai-sdk/google (catalog) for the model-id type

Verified: core tests + full typecheck pass; gemini-cli-3.5-flash passes
investigate-db-001-table-row-counts (3/3 checks) end-to-end in the sandbox.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Drop the gemini-cli-3.5-flash experiment; keep only gemini-3.1-pro-preview
  (Google's comparable to GPT-5.5 / Opus 4.8) and make it the runner default.
- Record reasoningEffort: "high" for it. gemini-cli has no flag to set effort —
  gemini-3.1-pro-preview thinks at high by default (inherited from chat-base-3) —
  so geminiCliAgent's reasoningEffort is display-only metadata (the runner
  ignores it) for benchmark parity with the other high-effort agents.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Rodriguespn
Rodriguespn force-pushed the pedrorodrigues/add-gemini-cli-agent-support branch from bb4372e to 221e191 Compare July 2, 2026 21:36
@Rodriguespn Rodriguespn removed the run-evals Add to a PR to refresh benchmark evals label Jul 2, 2026
Rodriguespn and others added 2 commits July 2, 2026 14:47
Validated gemini-cli 0.46.0's --output-format stream-json against the parser:
the event schema (init/message/tool_use/tool_result/result, field names, delta
merge, result.status) is unchanged from 0.20, so no parser/schema changes.

Two 0.46-specific fixes:
- Runner sets GEMINI_CLI_TRUST_WORKSPACE=true. Since 0.46 gemini refuses to run
  headless in an "untrusted" folder (exit 55) and silently downgrades
  --approval-mode yolo to prompt-for-approval — either of which breaks every
  sandbox run. The env var is ignored by versions that lack it.
- Map the new 0.46 built-in `update_topic` (session housekeeping) to agent_task
  instead of falling through to "unknown".

Verified end-to-end: gemini-cli-3.1-pro (CLI 0.46.0) passes
investigate-db-001 (3/3), tool calls paired, stop reason + effort metadata correct.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`max` is not a Gemini effort level; constrain the factory option to the
levels Gemini actually reports.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Rodriguespn
Rodriguespn marked this pull request as draft July 29, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant