feat(openab-agent): add Google Gemini provider (API key)#6
Open
Joseph19820124 wants to merge 2 commits into
Open
feat(openab-agent): add Google Gemini provider (API key)#6Joseph19820124 wants to merge 2 commits into
Joseph19820124 wants to merge 2 commits into
Conversation
|
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
|
Updated: ported Gemini 3.x
|
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>
…-flash Ports the thoughtSignature handling from the parallel feat/gemini-provider branch into this contained implementation: - Add optional thought_signature to ContentBlock::ToolUse and LlmEvent::ToolUse (serde-skipped when None; no effect on other providers). - parse_gemini_response captures the per-call thoughtSignature; the agent loop threads it onto the assistant ToolUse block; build_request_body echoes it back on the functionCall part. Gemini 3.x rejects multi-turn tool calls without this; <=2.5 ignores it. - Bump default Gemini model 2.0-flash -> 2.5-flash (docs + code). - 2 new tests (capture + echo); all existing provider sites updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
5f315b8 to
ae44ea1
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.
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/ContentBlock→ GeminigenerateContent: roleassistant→model,tool_use→functionCall,tool_result→functionResponse.functionResponseby function name, not an id → recovered from the originatingtool_use(gemini_tool_name).functionCalls carry no id → a stablecall_<name>_<idx>id is synthesized so the agent loop can pair the eventualtool_resultback.acp.rs): explicitOPENAB_AGENT_PROVIDER=gemini/google, plus auto-detect chainAnthropic key → Gemini key → Codex OAuth; error message updated.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).Scope
base = upstream-main(a pinned snapshot of currentopenabdev/openab@main), so the diff is exactly the single Gemini commit — independent of the Agent Skills PR (does not contain skills code).🤖 Generated with Claude Code