test_structured_output_retry_exceeds_max_retries() — langchain Function Reference
Architecture documentation for the test_structured_output_retry_exceeds_max_retries() function in test_structured_output_retry.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD b64a1d80_7fd8_7eef_2f67_1fdf14b55c4d["test_structured_output_retry_exceeds_max_retries()"] dd58b626_28b2_b72e_0314_162a5a760201["test_structured_output_retry.py"] b64a1d80_7fd8_7eef_2f67_1fdf14b55c4d -->|defined in| dd58b626_28b2_b72e_0314_162a5a760201 style b64a1d80_7fd8_7eef_2f67_1fdf14b55c4d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_structured_output_retry.py lines 139–184
def test_structured_output_retry_exceeds_max_retries() -> None:
"""Test structured output retry raises error when max retries exceeded."""
# All three attempts return invalid arguments
tool_calls = [
[
{
"name": "WeatherReport",
"id": "1",
"args": {"temperature": "invalid", "conditions": "sunny"},
}
],
[
{
"name": "WeatherReport",
"id": "2",
"args": {"temperature": "also-invalid", "conditions": "cloudy"},
}
],
[
{
"name": "WeatherReport",
"id": "3",
"args": {"temperature": "still-invalid", "conditions": "rainy"},
}
],
]
model = FakeToolCallingModel(tool_calls=tool_calls)
retry_middleware = StructuredOutputRetryMiddleware(max_retries=2)
agent = create_agent(
model=model,
tools=[get_weather],
middleware=[retry_middleware],
response_format=ToolStrategy(schema=WeatherReport, handle_errors=False),
# No checkpointer - we expect this to fail
)
# Should raise StructuredOutputError after exhausting retries
with pytest.raises(StructuredOutputError):
agent.invoke(
{"messages": [HumanMessage("What's the weather in Tokyo?")]},
)
# Verify the model was called 3 times (initial + 2 retries)
assert model.index == 3
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_structured_output_retry_exceeds_max_retries() do?
test_structured_output_retry_exceeds_max_retries() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_structured_output_retry.py.
Where is test_structured_output_retry_exceeds_max_retries() defined?
test_structured_output_retry_exceeds_max_retries() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_structured_output_retry.py at line 139.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free