Skip to content

Vertex structured output silently returns empty dict-typed fields (additionalProperties) #2889

Description

@CarSanoja

Summary

With a Pydantic response schema containing a plain dict field:

class AuditResult(BaseModel):
    mappings: dict[str, list[str]]

used as response_schema on Vertex (gemini-3.5-flash-lite, location global), the model is explicitly instructed to return e.g.
{"mappings": {"alg-factor-1": ["A-SSE.2"]}} — and the API response contains "mappings": {} every time. No error, no warning: dict[str, ...] compiles to JSON-Schema additionalProperties, which Vertex structured output does not
honor, so the field arrives empty.

Why this is worse than a rejection

The call succeeds and validates. In our grading pipeline the curriculum-audit agent silently reported zero curriculum coverage for weeks of development — the feature was fully dead in production while every test on the SDK surface passed. A hard error on unsupported schema constructs (or dropping the field from the generated schema with a warning) would have surfaced this instantly.

Reproduction

  1. Define the model above; call generate_content on Vertex with response_mime_type="application/json", response_schema=AuditResult.
  2. Prompt: "Return mappings = {'alg-factor-1': ['A-SSE.2']}".
  3. Observe mappings == {} in the parsed response.

Workaround we shipped: a list-shaped wire model ([{"criterion_id": ..., "competency_codes": [...]}]) converted back to the
dict-shaped domain model after parsing.

Environment

google-genai 2.18.1 (Vertex mode), gemini-3.5-flash-lite @ global, Python 3.13. Found while building a K-12 exam-grading fleet for the All Things Agentic hackathon.

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions