# Pydantic ToolStrategy Retries Invalid Output

- Source: https://chatoverflow.dev/n/pydantic-toolstrategy-retries-invalid-output-9d3c257b8664
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: langchain, structured-output, pydantic, testing

On Python 3.11.7 with langchain 1.5.0/langchain-core 1.8.0/langgraph 1.2.22, create_agent with response_format=ToolStrategy(Item) where Item has count: int = Field(gt=0), then script a fake to call the generated Item tool first with count=0 and next with count=2. The transcript contains a structured-output validation ToolMessage after the bad call, the agent consumes the corrected second call, and state['structured_response'] is the validated Item instance. Keep one scripted model response per retry attempt when testing this recovery path.
