~ LOSSY

pydantic-ai 2.61.0

truncation.structured-output · anthropic

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="{\"islands\":[{\"name\":\"Κρήτη\",\"sea\":" (raw); truth.text="{\"islands\":[{\"name\":\"Κρήτη\",\"sea\":"
usage-reportedSHOULDNOT_OBSERVABLEusage.input=25 (raw); truth.usage.input=25; usage.output=24 (raw); truth.usage.output=24

Notes

  • shim: retries: 1 (2 model requests)

What the provider sent

Finish
length
Raw finish
max_tokens
Text
{"islands":[{"name":"Κρήτη","sea":
Tool calls
[]
Usage
{
  "alternatives": {},
  "cached_input": null,
  "input": 25,
  "output": 24,
  "raw": {
    "input_tokens": 25,
    "output_tokens": 24,
    "output_tokens_details": {
      "thinking_tokens": 4
    }
  },
  "reasoning": 4,
  "total": 49
}
Stream completed
null
Error
null
Wire excerpt
status: 200
content-type: application/json
body (json):
{
  "id": "msg_01Aq9w938a90dw8q",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "thinking",
      "thinking": "",
      "signature": "EqQBCgIYAhIM1gbcDa9GJwZA2b3hGgxBdjrkzLoky3dl1pkiMOYds..."
    },
    {
      "type": "text",
      "text": "{\"islands\":[{\"name\":\"Κρήτη\",\"sea\":"
    }
  ],
  "model": "claude-sonnet-5-5",
  "stop_reason": "max_tokens",
  "stop_sequence": null,
  "stop_details": null,
  "usage": {
    "input_tokens": 25,
    "output_tokens": 24,
    "output_tokens_details": {
      "thinking_tokens": 4
    }
  }
}

What the library reported

Outcome
raised
Finish
{
  "raw": "max_tokens",
  "source": "ModelResponse.finish_reason",
  "surface": "raw",
  "value": "length"
}
Text
Value
{"islands":[{"name":"Κρήτη","sea":
Surface
raw
Tool calls
[]
Usage
{
  "cached_input": 0,
  "input": 25,
  "output": 24,
  "reasoning": 4,
  "surface": {
    "cached_input": "raw",
    "input": "raw",
    "output": "raw",
    "reasoning": "raw",
    "total": "raw"
  },
  "total": 49
}
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": 272.243382409215,
  "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": "{\"islands\":[{\"name\":\"Κρήτη\",\"sea\":"
  },
  "tool_calls": [],
  "unsupported_reason": null,
  "usage": {
    "cached_input": 0,
    "input": 25,
    "output": 24,
    "reasoning": 4,
    "surface": {
      "cached_input": "raw",
      "input": "raw",
      "output": "raw",
      "reasoning": "raw",
      "total": "raw"
    },
    "total": 49
  }
}

Fixture

documented anthropic/truncation.structured-output

ProvenanceValue
Sourcehttps://platform.claude.com/docs/en/build-with-claude/structured-outputs#invalid-outputs
NotesDocumented shapes, not a recording. Message envelope and stop fields follow handling-stop-reasons; content blocks follow thinking/streaming and handle-tool-calls. Model changed to claude-sonnet-5-5; IDs and scenario text are filled in. Token counts are illustrative, filled in to include thinking within the requested output limit, not measured. The native request uses output_config.format. ASSUMED partial Greek JSON prefix and thinking block at max_tokens; the docs describe incomplete structured output but do not print this exact envelope. The output_tokens_details.thinking_tokens breakdown follows thinking-steering.md (https://platform.claude.com/docs/en/build-with-claude/thinking-steering-and-cost#pricing); the thinking count of 4 is filled in, not measured.

Reproduce

wiretruth serve anthropic/truncation.structured-output

Plain-library snippet from the shim manifest.

AnthropicModel(model, provider=AnthropicProvider(base_url=WIRETRUTH_BASE_URL_ANTHROPIC, 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