-
Notifications
You must be signed in to change notification settings - Fork 451
Description
Checks
- I have updated to the lastest minor and patch version of Strands
- I have checked the documentation and this is not expected behavior
- I have searched ./issues and there are no duplicates of my issue
Strands Version
1.12.0
Python Version
3.12.11
Operating System
macOS 15.6
Installation Method
other
Steps to Reproduce
-
Set the environment variable to enable Vertex AI mode:
import os os.environ["GOOGLE_GENAI_USE_VERTEXAI"] = "True"
-
Create an agent without tools:
from strands import Agent from strands.models.gemini import GeminiModel # This fails with 400 INVALID_ARGUMENT Agent(model=GeminiModel(model_id="gemini-2.5-flash"))("who are you?")
-
Observe the error
Note: Creating an agent WITH tools works correctly:from strands_tools import calculator Agent(model=GeminiModel(model_id="gemini-2.5-flash"), tools=[calculator])("who are you?") # Works fine
Expected Behavior
Agents without tools should work correctly in both Vertex AI mode and standard Gemini API mode.
Actual Behavior
When using Vertex AI mode, the agent fails with the following error:
google.genai.errors.ClientError: 400 INVALID_ARGUMENT.
{'error': {'code': 400, 'message': "The GenerateContentRequest proto is invalid:\n
* tools[0].tool_type: required one_of 'tool_type' must have one initialized field",
'status': 'INVALID_ARGUMENT'}}- ✅ Works correctly with standard Gemini API (using API key)
- ❌ Fails in Vertex AI mode (
GOOGLE_GENAI_USE_VERTEXAI=True)
Additional Context
Environment:
- Model: gemini-2.5-flash (and other Gemini models)
- Deployment mode: Vertex AI (
GOOGLE_GENAI_USE_VERTEXAI=True)
Impact:
- 6 integration tests failing in
test_model_gemini.pywhen run in Vertex AI mode - Users cannot create agents without tools when using Vertex AI
Root Cause:
The current implementation always sends an empty tools array when no tools are provided. Vertex AI's backend strictly enforces the oneof proto definition for FunctionDeclarations, which does not accept empty arrays. The standard Gemini API is more lenient and accepts empty arrays.
Possible Solution
Modify _format_request_config in src/strands/models/gemini.py to only include the tools field when tools are actually provided:
tools=self._format_request_tools(tool_specs) if tool_specs else None,This approach omits the tools field entirely when no tools are provided, which is accepted by both Vertex AI and the standard Gemini API.
Related Issues
No response