~ LOSSY

pydantic-ai 2.61.0

truncation.structured-output · gemini

Back to results · Scenario

Requirements

IdLevelStatusEvidence
no-partial-successMUSTSATISFIEDstructured.attempted=true; structured.returned_as_success=false
cause-is-truncationMUSTNOT_OBSERVABLEfinish.value="length" (raw: ModelResponse.finish_reason); truth.finish="length"; error.category="parse"; structured.returned_as_success=false
text-reportedSHOULDNOT_OBSERVABLEtext.value="{\n \"islands\":" (raw); truth.text="{\n \"islands\":"
usage-reportedSHOULDNOT_OBSERVABLEusage.input=19 (raw); truth.usage.input=19; usage.output=7 (raw); truth.usage.output=7

Notes

  • shim: retries: 1 (2 model requests)

What the provider sent

Finish
length
Raw finish
MAX_TOKENS
Text
{ "islands":
Tool calls
[]
Usage
{
  "alternatives": {},
  "cached_input": null,
  "input": 19,
  "output": 7,
  "raw": {
    "candidatesTokenCount": 7,
    "promptTokenCount": 19,
    "promptTokensDetails": [
      {
        "modality": "TEXT",
        "tokenCount": 19
      }
    ],
    "serviceTier": "standard",
    "totalTokenCount": 26
  },
  "reasoning": null,
  "total": 26
}
Stream completed
null
Error
null
Wire excerpt
status: 200
content-type: application/json; charset=UTF-8
body (json):
{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "text": "{\n  \"islands\":",
            "thoughtSignature": "EmAKXgFpFH0TRpy3JZL2qd/cDtQmrps9PxfnU8+ovCZz1iEJU700MutHK0ZD2fh0jH2jIqIzPwG+U7gpx2LlBGanxSVs64JLIvaxP9PYvF/lXUxs9Yud2C1/hs4Hi8FAvMg="
          }
        ],
        "role": "model"
      },
      "finishReason": "MAX_TOKENS",
      "index": 0
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 19,
    "candidatesTokenCount": 7,
    "totalTokenCount": 26,
    "promptTokensDetails": [
      {
        "modality": "TEXT",
        "tokenCount": 19
      }
    ],
    "serviceTier": "standard"
  },
  "modelVersion": "gemini-3.5-flash-lite",
  "responseId": "lwTOap6OEvjljMcPvYSCgAU"
}

What the library reported

Outcome
raised
Finish
{
  "raw": "MAX_TOKENS",
  "source": "ModelResponse.finish_reason",
  "surface": "raw",
  "value": "length"
}
Text
Value
{ "islands":
Surface
raw
Tool calls
[]
Usage
{
  "cached_input": 0,
  "input": 19,
  "output": 7,
  "reasoning": 0,
  "surface": {
    "cached_input": "raw",
    "input": "raw",
    "output": "raw",
    "reasoning": "raw",
    "total": "raw"
  },
  "total": 26
}
Stream
{
  "chunks_seen": null,
  "completed": null,
  "used": false
}
Error
Type
pydantic_ai.exceptions.UnexpectedModelBehavior
Message
Exceeded maximum output retries (1)
Category
parse
Retry after
null
Stack top
pydantic_ai/_agent_graph.py:472
Unsupported reason
null
Full observation JSON
{
  "elapsed_ms": 349.61640648543835,
  "error": {
    "category": "parse",
    "message": "Exceeded maximum output retries (1)",
    "retry_after": null,
    "stack_top": "pydantic_ai/_agent_graph.py:472",
    "type": "pydantic_ai.exceptions.UnexpectedModelBehavior"
  },
  "finish": {
    "raw": "MAX_TOKENS",
    "source": "ModelResponse.finish_reason",
    "surface": "raw",
    "value": "length"
  },
  "format": "wiretruth.observation/v1",
  "library": {
    "api": "Agent.run",
    "language": "python",
    "name": "pydantic-ai",
    "version": "2.61.0"
  },
  "notes": [
    "retries: 1 (2 model requests)"
  ],
  "outcome": "raised",
  "stream": {
    "chunks_seen": null,
    "completed": null,
    "used": false
  },
  "structured": {
    "attempted": true,
    "returned_as_success": false,
    "value": null
  },
  "text": {
    "surface": "raw",
    "value": "{\n  \"islands\":"
  },
  "tool_calls": [],
  "unsupported_reason": null,
  "usage": {
    "cached_input": 0,
    "input": 19,
    "output": 7,
    "reasoning": 0,
    "surface": {
      "cached_input": "raw",
      "input": "raw",
      "output": "raw",
      "reasoning": "raw",
      "total": "raw"
    },
    "total": 26
  }
}

Fixture

recorded gemini/truncation.structured-output

ProvenanceValue
Recorded at2026-10-13T10:14:47Z
Requested modelgemini-3.5-flash-lite
Returned modelgemini-3.5-flash-lite
CI runhttps://github.com/kartsan03/wiretruth/actions/runs/38381941285

Reproduce

wiretruth serve gemini/truncation.structured-output

Plain-library snippet from the shim manifest.

GoogleModel(model, provider=GoogleProvider(base_url=WIRETRUTH_BASE_URL_GEMINI, api_key=WIRETRUTH_API_KEY)); host root

Upstream

confirmed Issue · PR

Fixed in: not specified

Existing upstream issue, opened by a maintainer, not by wiretruth. Cut-off structured output is retried, then fails with UnexpectedModelBehavior('Exceeded maximum output retries'); the length finish is only in the captured messages. https://github.com/pydantic/pydantic-ai/pull/12406, merged after 2.66.0 and not in a release yet, raises right away with a message naming the token limit; https://github.com/pydantic/pydantic-ai/pull/12407 (open) adds the typed OutputTokenLimitExceeded.

History

VersionGrade
2.61.0~ LOSSY
2.56.0~ LOSSY