Home / Function/ test_model_retry_async_failing_model() — langchain Function Reference

test_model_retry_async_failing_model() — langchain Function Reference

Architecture documentation for the test_model_retry_async_failing_model() function in test_model_retry.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  5245322c_24ce_eb24_a602_bfbdd00b3b6f["test_model_retry_async_failing_model()"]
  6a114635_155a_5b86_2f48_fb8ca99f7545["test_model_retry.py"]
  5245322c_24ce_eb24_a602_bfbdd00b3b6f -->|defined in| 6a114635_155a_5b86_2f48_fb8ca99f7545
  style 5245322c_24ce_eb24_a602_bfbdd00b3b6f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_model_retry.py lines 544–571

async def test_model_retry_async_failing_model() -> None:
    """Test ModelRetryMiddleware with async execution and failing model."""
    model = AlwaysFailingModel(error_message="Model error", error_type=ValueError)

    retry = ModelRetryMiddleware(
        max_retries=2,
        initial_delay=0.01,
        jitter=False,
        on_failure="continue",
    )

    agent = create_agent(
        model=model,
        tools=[],
        middleware=[retry],
        checkpointer=InMemorySaver(),
    )

    result = await agent.ainvoke(
        {"messages": [HumanMessage("Hello")]},
        {"configurable": {"thread_id": "test"}},
    )

    ai_messages = [m for m in result["messages"] if isinstance(m, AIMessage)]
    assert len(ai_messages) >= 1
    last_msg = ai_messages[-1].content
    assert "failed after 3 attempts" in last_msg
    assert "ValueError" in last_msg

Domain

Subdomains

Frequently Asked Questions

What does test_model_retry_async_failing_model() do?
test_model_retry_async_failing_model() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_model_retry.py.
Where is test_model_retry_async_failing_model() defined?
test_model_retry_async_failing_model() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_model_retry.py at line 544.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free