feat(openab-agent): add Google Gemini provider (API key)#4
Closed
Joseph19820124 wants to merge 1 commit into
Closed
feat(openab-agent): add Google Gemini provider (API key)#4Joseph19820124 wants to merge 1 commit into
Joseph19820124 wants to merge 1 commit into
Conversation
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>
|
All PRs must reference a prior Discord discussion to ensure community alignment before implementation. Please edit the PR description to include a link like: This PR will be automatically closed in 3 days if the link is not added. |
Owner
Author
|
Superseded by two independent PRs against |
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.
What
Adds a Google Gemini provider to
openab-agent, mirroring the existingAnthropicProviderAPI-key pattern.The Gemini provider
GeminiProviderinopenab-agent/src/llm.rs, modeled exactly onAnthropicProvider:from_env()readsGEMINI_API_KEY, falling back toGOOGLE_API_KEY— same shape asAnthropicProviderreadingANTHROPIC_API_KEY. No OAuth.Message/ContentBlockmodel to Gemini'sgenerateContent:assistant→modeltool_use→functionCalltool_result→functionResponsefunctionResponseby the function name, not an id → the name is recovered from the originatingtool_useblock (gemini_tool_name).functionCalls carry no id → a stable idcall_<name>_<idx>is synthesized so the agent loop can pair the eventualtool_resultback to the call.acp.rs): explicitOPENAB_AGENT_PROVIDER=gemini/google, plus the auto-detect chainAnthropic key → Gemini key → Codex OAuth. Error message updated to mentionGEMINI_API_KEY.OPENAB_AGENT_MODEL(defaultgemini-2.0-flash),OPENAB_AGENT_GEMINI_BASE_URL.Tests & checks
cargo test— 30 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.mdupdated (env-var table + auth section).Notes
gemini-2.0-flashis deliberately conservative; override viaOPENAB_AGENT_MODEL.openabdev/openabis untouched.main: main...feat/gemini-provider-and-skills🤖 Generated with Claude Code