Skip to content

feat(openab-agent): add Google Gemini provider (API key)#4

Closed
Joseph19820124 wants to merge 1 commit into
skillsfrom
feat/gemini-provider-and-skills
Closed

feat(openab-agent): add Google Gemini provider (API key)#4
Joseph19820124 wants to merge 1 commit into
skillsfrom
feat/gemini-provider-and-skills

Conversation

@Joseph19820124
Copy link
Copy Markdown
Owner

What

Adds a Google Gemini provider to openab-agent, mirroring the existing AnthropicProvider API-key pattern.

Review scope: this PR's base is the skills branch (a verbatim copy of upstream PR openabdev#955 "feat(openab-agent): add skill support"), so the diff here is only the Gemini commit — the skills code is excluded from review noise. The full branch-vs-main view (skills + Gemini) is at the compare link below.

The Gemini provider

GeminiProvider in openab-agent/src/llm.rs, modeled exactly on AnthropicProvider:

  • Credentials: from_env() reads GEMINI_API_KEY, falling back to GOOGLE_API_KEY — same shape as AnthropicProvider reading ANTHROPIC_API_KEY. No OAuth.
  • Format mapping: translates the internal Anthropic-shaped Message/ContentBlock model to Gemini's generateContent:
    • role assistantmodel
    • tool_usefunctionCall
    • tool_resultfunctionResponse
  • Two impedance mismatches handled:
    • Gemini keys a functionResponse by the function name, not an id → the name is recovered from the originating tool_use block (gemini_tool_name).
    • Gemini functionCalls carry no id → a stable id call_<name>_<idx> is synthesized so the agent loop can pair the eventual tool_result back to the call.
  • Retries: 429 / 503 with exponential backoff, like the other providers.
  • Wiring (acp.rs): explicit OPENAB_AGENT_PROVIDER=gemini/google, plus the auto-detect chain Anthropic key → Gemini key → Codex OAuth. Error message updated to mention GEMINI_API_KEY.
  • Config: OPENAB_AGENT_MODEL (default gemini-2.0-flash), OPENAB_AGENT_GEMINI_BASE_URL.

Tests & checks

  • cargo test30 passed / 0 failed (5 new Gemini tests: role mapping, tool_result keyed-by-name, error field, parse text/functionCall, error envelope).
  • cargo build, cargo fmt --check, cargo clippy — clean (Gemini code: 0 warnings).
  • docs/native-agent.md updated (env-var table + auth section).

Notes

  • Default model gemini-2.0-flash is deliberately conservative; override via OPENAB_AGENT_MODEL.
  • Opened inside this fork only — upstream openabdev/openab is untouched.
  • Full branch (skills + Gemini) vs fork main: main...feat/gemini-provider-and-skills

🤖 Generated with Claude Code

Mirror the AnthropicProvider API-key pattern for Google Gemini:

- GeminiProvider::from_env() reads GEMINI_API_KEY (falls back to
  GOOGLE_API_KEY), mirroring AnthropicProvider's ANTHROPIC_API_KEY path.
- Maps our Anthropic-shaped Message/ContentBlock model onto Gemini's
  generateContent format: role assistant->model, tool_use->functionCall,
  tool_result->functionResponse. Gemini keys functionResponse by function
  NAME (not id), so the name is recovered from the originating tool_use;
  function-call ids are synthesized (call_<name>_<idx>) so the agent loop
  can still pair results back.
- Retries on 429/503 with exponential backoff, like the other providers.
- Wired into acp.rs provider selection: explicit 'gemini'/'google', plus
  the auto-detect chain (Anthropic key -> Gemini key -> Codex OAuth).
- Configurable via OPENAB_AGENT_MODEL (default gemini-2.0-flash) and
  OPENAB_AGENT_GEMINI_BASE_URL. Docs + 5 unit tests added.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions github-actions Bot added closing-soon pending-screening PR awaiting automated screening labels May 31, 2026
@github-actions
Copy link
Copy Markdown

⚠️ This PR is missing a Discord Discussion URL in the body.

All PRs must reference a prior Discord discussion to ensure community alignment before implementation.

Please edit the PR description to include a link like:

Discord Discussion URL: https://discord.com/channels/...

This PR will be automatically closed in 3 days if the link is not added.

@Joseph19820124
Copy link
Copy Markdown
Owner Author

Superseded by two independent PRs against upstream-main: #5 (Agent Skills, replicating upstream openabdev#955) and #6 (Google Gemini provider). This stacked PR (Gemini on top of skills) is no longer needed.

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

Labels

closing-soon pending-screening PR awaiting automated screening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant