feat: add the Gemini agent driver (@agentry/gemini) - #4
Merged
Conversation
…e workspace New workspace package mirroring @agentry/claude; adds the tsconfig path, vitest alias, and CLI dependency so the driver resolves across typecheck, tests, and the CLI. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… Agentry event model parseGeminiEvents is a pure whole-stream mapper: init, message, tool_use, tool_result, error, result. Gemini streams assistant text as delta chunks, so consecutive assistant deltas are coalesced into a single message (one turn); usage and run.end come from the terminal result event. Schema captured live from gemini-cli 0.54.4. Constraint: Assistant text arrives as streaming deltas and must be coalesced, else turns/lastMessage inflate Rejected: Declare base-URL LLM interception | unproven for Gemini, so capabilities report 'none' and the proxy is not wired\nConfidence: high\nScope-risk: narrow\nDirective: buildArgs must pass --skip-trust; gemini 0.5x refuses untrusted workspaces headlessly\nNot-tested: mcpConfig / appendSystemPrompt passthrough (ignored in MVP)\nCo-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Fixtures are the live-captured gemini-cli 0.54.4 stream; asserts delta coalescing (one assistant message), tool calls, usage, and run.end. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
selectDriver(config.use.agent) routes 'gemini' to GeminiDriver and defaults to Claude; doctor probes the gemini CLI and prints its capabilities. Constraint: Parallel driver branches each extend this switch; kept minimal for clean union merges Confidence: high Scope-risk: narrow Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
dortort
force-pushed
the
feat/gemini-driver
branch
from
August 8, 2026 21:01
a649ccc to
e1cc893
Compare
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
Adds
@agentry/gemini, a driver that drives the Gemini CLI headlessly viagemini -p --output-format stream-jsonand normalizes its native stream into the shared AgentryAgentEventmodel — the same contract@agentry/claudeimplements. Wires it into the CLI soagentry test/recordcan target Gemini withuse: { agent: 'gemini' }.Delivers part of the Phase 5 "cross-agent adapters" roadmap item (spike-gated).
How it works
The event schema was captured live from gemini-cli 0.54.4 (the Phase 0.12 feasibility spike) and cross-checked against the CLI's bundled
StreamJsonFormatter.parseGeminiEventsis a pure whole-stream mapper:--output-format stream-json)initrun.startmessage{role,content,delta?}messagetool_use{tool_name,tool_id,parameters}tool_usetool_result{tool_id,status,output}tool_resulterror{severity,message}errorresult{status,stats}usage+run.endKey detail: Gemini streams assistant text as multiple
{role:"assistant", delta:true}chunks. The parser coalesces consecutive assistant deltas into a single message (soturns/lastMessagestay correct) — this is why it's whole-stream rather than per-event. Usage andrun.endcome from the terminalresultevent. Spawns with stdin ignored.Capabilities
Known limitations (MVP)
buildArgspasses--skip-trust— gemini 0.5x refuses untrusted workspaces in headless mode.'none'and not wired to Agentry's proxy. Transcript record/replay works; wire cassettes do not apply.disallowedTools/mcpConfig/maxBudgetUSD/appendSystemPrompthave no direct headless equivalent and are ignored.Testing
pnpm typecheckclean; new-package tests green (parser incl. delta coalescing +buildArgs); full suite 92 tests, 0 failures, no regressions.agentry doctorprobes the gemini CLI and prints the driver's capabilities.Merge notes
main. Additively touches three files the sibling Codex/Antigravity PRs also touch — theselectDriverswitch inpackages/cli/src/commands/run.ts,doctor.ts, and thetsconfig.json/vitest.config.tsaliases. Whichever PR merges later needs a trivial union-merge.chore/release-workflow. When that lands, add@agentry/geminito the fixed-version group and a changeset entry.IneligibleTierError); an API key (GEMINI_API_KEY) works. Relevant for anyone running live/record mode.🤖 Generated with Claude Code