π΄ Required Information
Describe the Bug:
The same agent app runs correctly on the Gemini Developer API (AI Studio) but fails on Vertex AI (GOOGLE_GENAI_USE_VERTEXAI=1), due to two distinct problems:
Schema validation on Vertex: Pydantic output_schema and tool parameters containing Optional/Union/Literal fields serialize to JSON Schema anyOf. Vertex AI rejects these with: Unable to submit request because ... functionDeclaration ... schema didn't specify the schema type field. The identical request succeeds on AI Studio. Matches googleapis/python-genai#1807.
Dropped function calls in streaming: When output_schema is combined with function-calling tools and BuiltInPlanner thinking in SSE mode, the streaming loop can terminate before the function-call response arrives, leaving an empty string that fails Pydantic validation. Matches #3599 (currently closed) and the output_schema + tools incompatibility in #3025.
Steps to Reproduce:
Install google-adk 1.18.0 (with google-genai 1.75.0)
Define an LlmAgent with output_schema = a Pydantic model containing at least one Optional[list[str]] field, one function tool, and planner=BuiltInPlanner(thinking_config=ThinkingConfig(include_thoughts=True)) β see Minimal Reproduction Code below
Run with GOOGLE_GENAI_USE_VERTEXAI=0 (AI Studio) and send a query via SSE streaming β succeeds
Run the same query with GOOGLE_GENAI_USE_VERTEXAI=1 + GOOGLE_CLOUD_PROJECT/GOOGLE_CLOUD_LOCATION set β fails with the schema type error above (and, when tools are invoked, an empty final response that fails Pydantic validation)
Expected Behavior:
Parity between the AI Studio and Vertex AI backends for the same agent definition β Vertex should accept anyOf schemas (or ADK should emit Vertex-compatible schemas), and output_schema + tools + thinking should return the function-call result under streaming.
Observed Behavior:
Works on AI Studio; fails on Vertex AI:
Schema rejection: Unable to submit request because ... functionDeclaration ... schema didn't specify the schema type field.
When tools are called under SSE streaming with thinking enabled, the final response arrives as an empty string, which fails Pydantic validation against output_schema.
Environment Details:
ADK Library Version (pip show google-adk): 1.18.0 (google-genai 1.75.0)
Desktop OS: macOS 26.4.1 (arm64 / Apple Silicon)
Python Version (python -V): 3.12.13
Model Information:
Are you using LiteLLM: No
Which model is being used: gemini-2.5-flash
π‘ Optional Information
Regression:
Unknown β this is our first attempt at running the agent on the Vertex AI backend; the AI Studio backend has always worked with the same definition.
Logs:
Full traceback to be attached shortly β the JSON snippet in Additional Context below is the exact schema construct Vertex rejects per googleapis/python-genai#1807.
Additional Context:
Architecture: one orchestrator LlmAgent with output_schema=CoordinatorResponse, plus 4 sub-agents exposed as tools via AgentTool (each with its own output_schema); BuiltInPlanner(ThinkingConfig(include_thoughts=True)); SSE streaming.
Evidence β the Optional[list[str]] field serializes to exactly the anyOf-without-top-level-type construct that Vertex rejects per googleapis/python-genai#1807 (verified locally with pydantic's model_json_schema()):
json"sources": {
"anyOf": [
{"items": {"type": "string"}, "type": "array"},
{"type": "null"}
],
"default": null,
"title": "Sources"
}
Related issues:
googleapis/python-genai#1807 β Vertex AI anyOf schema validation
#3599 β reasoning + output_schema + tools under streaming
#3025 β tools + output_schema incompatibility
#1018 β thinking_config on 2.5 models
Minimal Reproduction Code:
pythonfrom pydantic import BaseModel
from google.adk.agents import LlmAgent
from google.adk.planners import BuiltInPlanner
from google.genai import types
class CoordinatorResponse(BaseModel):
answer: str
sources: list[str] | None = None # serializes to anyOf -> rejected by Vertex
def get_weather(city: str) -> dict:
"""Return a dummy weather forecast for a city."""
return {"city": city, "forecast": "sunny"}
root_agent = LlmAgent(
name="coordinator",
model="gemini-2.5-flash",
instruction="Answer the question. Use tools when needed.",
tools=[get_weather],
output_schema=CoordinatorResponse,
planner=BuiltInPlanner(
thinking_config=types.ThinkingConfig(include_thoughts=True)
),
)
Run via adk web (SSE streaming) or a Runner.
GOOGLE_GENAI_USE_VERTEXAI=0 -> works (AI Studio)
GOOGLE_GENAI_USE_VERTEXAI=1 + project -> fails (Vertex AI)
How often has this issue occurred?:
Always (100%)
π΄ Required Information
Describe the Bug:
The same agent app runs correctly on the Gemini Developer API (AI Studio) but fails on Vertex AI (GOOGLE_GENAI_USE_VERTEXAI=1), due to two distinct problems:
Schema validation on Vertex: Pydantic output_schema and tool parameters containing Optional/Union/Literal fields serialize to JSON Schema anyOf. Vertex AI rejects these with: Unable to submit request because ... functionDeclaration ... schema didn't specify the schema type field. The identical request succeeds on AI Studio. Matches googleapis/python-genai#1807.
Dropped function calls in streaming: When output_schema is combined with function-calling tools and BuiltInPlanner thinking in SSE mode, the streaming loop can terminate before the function-call response arrives, leaving an empty string that fails Pydantic validation. Matches #3599 (currently closed) and the output_schema + tools incompatibility in #3025.
Steps to Reproduce:
Install google-adk 1.18.0 (with google-genai 1.75.0)
Define an LlmAgent with output_schema = a Pydantic model containing at least one Optional[list[str]] field, one function tool, and planner=BuiltInPlanner(thinking_config=ThinkingConfig(include_thoughts=True)) β see Minimal Reproduction Code below
Run with GOOGLE_GENAI_USE_VERTEXAI=0 (AI Studio) and send a query via SSE streaming β succeeds
Run the same query with GOOGLE_GENAI_USE_VERTEXAI=1 + GOOGLE_CLOUD_PROJECT/GOOGLE_CLOUD_LOCATION set β fails with the schema type error above (and, when tools are invoked, an empty final response that fails Pydantic validation)
Expected Behavior:
Parity between the AI Studio and Vertex AI backends for the same agent definition β Vertex should accept anyOf schemas (or ADK should emit Vertex-compatible schemas), and output_schema + tools + thinking should return the function-call result under streaming.
Observed Behavior:
Works on AI Studio; fails on Vertex AI:
Schema rejection: Unable to submit request because ... functionDeclaration ... schema didn't specify the schema type field.
When tools are called under SSE streaming with thinking enabled, the final response arrives as an empty string, which fails Pydantic validation against output_schema.
Environment Details:
ADK Library Version (pip show google-adk): 1.18.0 (google-genai 1.75.0)
Desktop OS: macOS 26.4.1 (arm64 / Apple Silicon)
Python Version (python -V): 3.12.13
Model Information:
Are you using LiteLLM: No
Which model is being used: gemini-2.5-flash
π‘ Optional Information
Regression:
Unknown β this is our first attempt at running the agent on the Vertex AI backend; the AI Studio backend has always worked with the same definition.
Logs:
Full traceback to be attached shortly β the JSON snippet in Additional Context below is the exact schema construct Vertex rejects per googleapis/python-genai#1807.
Additional Context:
Architecture: one orchestrator LlmAgent with output_schema=CoordinatorResponse, plus 4 sub-agents exposed as tools via AgentTool (each with its own output_schema); BuiltInPlanner(ThinkingConfig(include_thoughts=True)); SSE streaming.
Evidence β the Optional[list[str]] field serializes to exactly the anyOf-without-top-level-type construct that Vertex rejects per googleapis/python-genai#1807 (verified locally with pydantic's model_json_schema()):
json"sources": {
"anyOf": [
{"items": {"type": "string"}, "type": "array"},
{"type": "null"}
],
"default": null,
"title": "Sources"
}
Related issues:
googleapis/python-genai#1807 β Vertex AI anyOf schema validation
#3599 β reasoning + output_schema + tools under streaming
#3025 β tools + output_schema incompatibility
#1018 β thinking_config on 2.5 models
Minimal Reproduction Code:
pythonfrom pydantic import BaseModel
from google.adk.agents import LlmAgent
from google.adk.planners import BuiltInPlanner
from google.genai import types
class CoordinatorResponse(BaseModel):
answer: str
sources: list[str] | None = None # serializes to anyOf -> rejected by Vertex
def get_weather(city: str) -> dict:
"""Return a dummy weather forecast for a city."""
return {"city": city, "forecast": "sunny"}
root_agent = LlmAgent(
name="coordinator",
model="gemini-2.5-flash",
instruction="Answer the question. Use tools when needed.",
tools=[get_weather],
output_schema=CoordinatorResponse,
planner=BuiltInPlanner(
thinking_config=types.ThinkingConfig(include_thoughts=True)
),
)
Run via
adk web(SSE streaming) or a Runner.GOOGLE_GENAI_USE_VERTEXAI=0 -> works (AI Studio)
GOOGLE_GENAI_USE_VERTEXAI=1 + project -> fails (Vertex AI)
How often has this issue occurred?:
Always (100%)