feat(providers): route gemini through the native AI Studio API#12656
Closed
kshitijk4poor wants to merge 3 commits into
Closed
feat(providers): route gemini through the native AI Studio API#12656kshitijk4poor wants to merge 3 commits into
kshitijk4poor wants to merge 3 commits into
Conversation
- add a native Gemini adapter over generateContent/streamGenerateContent - switch the built-in gemini provider off the OpenAI-compatible endpoint - preserve thought signatures and native functionResponse replay - route auxiliary Gemini clients through the same adapter - add focused unit coverage plus native-provider integration checks
Contributor
|
- only use the native adapter for the canonical Gemini native endpoint - keep custom and /openai base URLs on the OpenAI-compatible path - preserve Hermes keepalive transport injection for native Gemini clients - stabilize streaming tool-call replay across repeated SSE events - add follow-up tests for base_url precedence, async streaming, and duplicate tool-call chunks
- preserve explicit Gemini base_url/api_key in auxiliary auto routing - make native SSE parsing handle multiline data frames correctly - add regression tests for auxiliary base_url precedence and SSE parsing - document native Gemini defaults and explicit OpenAI-compatible overrides
Contributor
|
Merged via #12674 — your commits are on main with authorship preserved (3dea497, d393104). Salvage note: folded proxy-env support into the refactored |
This was referenced Apr 21, 2026
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
geminiprovider from Google's OpenAI-compatible endpoint to the native AI Studio APImodels/{model}:generateContentand:streamGenerateContent?alt=ssethoughtSignatureand correctfunctionResponse.name) while routing auxiliary Gemini calls through the same adapterWhy
The current first-class Gemini provider still rides the OpenAI-compatible endpoint, which has been brittle for Hermes's agent/tool loop (
#4983and the auth/tool-call fallout in#7893,#12127,#12168). Other agent repos that handle Gemini more reliably keep Gemini on its native request/response shape instead of treating it as plain OpenAI chat completions.This keeps Hermes's outer agent loop unchanged (
api_mode=chat_completions) but swaps the underlying transport to a native Gemini adapter.What changed
agent/gemini_native_adapter.py.chat.completions.create(...)contents,tools,toolConfig,generationConfig)status_code/retry_aftergeminiprovider default base URL tohttps://generativelanguage.googleapis.com/v1betarun_agent.pyto constructGeminiNativeClientfor the built-ingeminiprovideragent/auxiliary_client.pyso explicit/auto Gemini auxiliary clients use the same native adapter (including async wrapping)Test plan
bash scripts/run_tests.sh tests/agent/test_gemini_native_adapter.py tests/hermes_cli/test_gemini_provider.py -qbash scripts/run_tests.sh tests/agent/test_auxiliary_client.py tests/hermes_cli/test_gemini_provider.py tests/agent/test_gemini_native_adapter.py -qbash scripts/run_tests.sh tests/run_agent/test_run_agent.py tests/run_agent/test_streaming.py tests/agent/test_gemini_cloudcode.py -q -k 'tool_call_extra_content_preserved or gemini_cloudcode'/v1beta/models/gemini-2.5-flash:streamGenerateContent?alt=ssex-goog-api-keyauth headerfunctionResponsewith the original tool name