Add GeminiAgent for Google Gemini model support#451
Open
gavksingh wants to merge 2 commits into2FastLabs:mainfrom
Open
Add GeminiAgent for Google Gemini model support#451gavksingh wants to merge 2 commits into2FastLabs:mainfrom
gavksingh wants to merge 2 commits into2FastLabs:mainfrom
Conversation
Implement GeminiAgent and GeminiAgentOptions following the same pattern as OpenAIAgent, using the google-genai SDK. Supports both streaming and non-streaming responses, system prompts, retriever integration, and pre-configured client injection. - New file: agents/gemini_agent.py - Conditional import in agents/__init__.py (graceful when google-genai not installed) - New 'gemini' optional dependency group in setup.cfg - GEMINI_MODEL_ID_GEMINI_2_0_FLASH constant in types Fixes 2FastLabs#376
Unit tests cover initialization, client injection, custom prompts, streaming/non-streaming requests, retriever integration, and error handling. Integration test validates Vertex AI connectivity (requires GOOGLE_APPLICATION_CREDENTIALS). Registers 'integration' pytest marker.
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
GeminiAgentandGeminiAgentOptionsfor integrating Google Gemini models via thegoogle-genaiSDKOpenAIAgent— supports streaming/non-streaming, system prompts, retriever integration, and pre-configured client injectiongeminioptional dependency group (pip install agent-squad[gemini])google-genaiis not installed (conditional import)Files Changed
python/src/agent_squad/agents/gemini_agent.py— new agent implementationpython/src/agent_squad/agents/__init__.py— conditional import for GeminiAgentpython/setup.cfg—geminiextras group withgoogle-genai>=1.0.0python/src/agent_squad/types/types.py—GEMINI_MODEL_ID_GEMINI_2_0_FLASHconstantpython/src/agent_squad/types/__init__.py— export the new constantpython/src/tests/agents/test_gemini_agent.py— new test filepython/src/tests/pytest.ini— registeredintegrationmarkerTests added
New file:
python/src/tests/agents/test_gemini_agent.py(8 unit tests + 1 integration test)Unit tests:
test_gemini_agent_requires_api_key_or_client— ValueError when neither providedtest_gemini_agent_client_injection— pre-configured client bypasses api_key requirementtest_custom_system_prompt_with_variable— template{{variable}}resolved correctlytest_process_request_success— non-streaming returns ConversationMessagetest_process_request_streaming— streaming yields AgentStreamResponse chunks + final_messagetest_process_request_with_retriever— retriever called, context appendedtest_process_request_api_error— exception propagationtest_is_streaming_enabled— False default, True when setIntegration test (requires credentials):
test_gemini_vertex_ai_integration— end-to-end via Vertex AI withGOOGLE_APPLICATION_CREDENTIALSRun integration test with:
Test plan
from agent_squad.agents import GeminiAgentworks withgoogle-genaiinstalledgoogle-genaiis NOT installedpytest -v -m "not integration")Fixes #376