~ LOSSY

pydantic-ai 2.61.0

truncation.structured-output-forced-tool · 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="validation"; structured.returned_as_success=false
text-reportedSHOULDSATISFIEDtext.value=null (absent); truth.text=null
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
null
Tool calls
[
  {
    "arguments": {
      "islands": [
        {
          "name": "Κρήτη"
        }
      ]
    },
    "arguments_parsed_ok": true,
    "arguments_raw": "{\"islands\":[{\"name\":\"Κρήτη\"}]}",
    "id": "toolu_01A09q90qw90lq917835lq9",
    "name": "structured_output"
  }
]
Usage
{
  "alternatives": {},
  "cached_input": null,
  "input": 25,
  "output": 24,
  "raw": {
    "input_tokens": 25,
    "output_tokens": 24
  },
  "reasoning": null,
  "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": "tool_use",
      "id": "toolu_01A09q90qw90lq917835lq9",
      "name": "structured_output",
      "input": {
        "islands": [
          {
            "name": "Κρήτη"
          }
        ]
      }
    }
  ],
  "model": "claude-haiku-4-5",
  "stop_reason": "max_tokens",
  "stop_sequence": null,
  "stop_details": null,
  "usage": {
    "input_tokens": 25,
    "output_tokens": 24
  }
}

What the library reported

Outcome
raised
Finish
{
  "raw": "max_tokens",
  "source": "ModelResponse.finish_reason",
  "surface": "raw",
  "value": "length"
}
Text
Value
null
Surface
absent
Tool calls
[
  {
    "arguments": {
      "islands": [
        {
          "name": "Κρήτη"
        }
      ]
    },
    "arguments_parsed_ok": true,
    "arguments_raw": "{\"islands\":[{\"name\":\"Κρήτη\"}]}",
    "id": "toolu_01A09q90qw90lq917835lq9",
    "name": "structured_output"
  }
]
Usage
{
  "cached_input": 0,
  "input": 25,
  "output": 24,
  "reasoning": 0,
  "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
validation
Retry after
null
Stack top
pydantic_ai/_tool_execution.py:623
Unsupported reason
null
Full observation JSON
{
  "elapsed_ms": 284.88278947770596,
  "error": {
    "category": "validation",
    "message": "Exceeded maximum output retries (1)",
    "retry_after": null,
    "stack_top": "pydantic_ai/_tool_execution.py:623",
    "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": "absent",
    "value": null
  },
  "tool_calls": [
    {
      "arguments": {
        "islands": [
          {
            "name": "Κρήτη"
          }
        ]
      },
      "arguments_parsed_ok": true,
      "arguments_raw": "{\"islands\":[{\"name\":\"Κρήτη\"}]}",
      "id": "toolu_01A09q90qw90lq917835lq9",
      "name": "structured_output"
    }
  ],
  "unsupported_reason": null,
  "usage": {
    "cached_input": 0,
    "input": 25,
    "output": 24,
    "reasoning": 0,
    "surface": {
      "cached_input": "raw",
      "input": "raw",
      "output": "raw",
      "reasoning": "raw",
      "total": "raw"
    },
    "total": 49
  }
}

Fixture

documented anthropic/truncation.structured-output-forced-tool

ProvenanceValue
Sourcehttps://platform.claude.com/docs/en/agents-and-tools/tool-use/define-tools#forcing-tool-use
NotesDocumented shapes, not a recording. Message envelope follows handling-stop-reasons; tool_use object and forced tool choice follow define-tools. Model changed to claude-haiku-4-5; message ID follows the handle-tool-calls example. Scenario data and token counts are filled in, not measured. ASSUMED truncation: input stays an object as documented, but the island is missing its required sea. The docs do not show this exact forced Haiku truncation. No thinking block: forced tool use skips thinking. The call override supplies explicit tools and named tool_choice while output_schema retains the structured intent; no native output_config.format is sent.

Reproduce

wiretruth serve anthropic/truncation.structured-output-forced-tool

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