Home / Function/ test_tool_retry_deprecated_raise_behavior() — langchain Function Reference

test_tool_retry_deprecated_raise_behavior() — langchain Function Reference

Architecture documentation for the test_tool_retry_deprecated_raise_behavior() function in test_tool_retry.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  eced1d02_7caf_3dcf_3e0e_eccdb5936b8a["test_tool_retry_deprecated_raise_behavior()"]
  c71b26df_821f_59ac_c7ef_3b96fcbe0d5b["test_tool_retry.py"]
  eced1d02_7caf_3dcf_3e0e_eccdb5936b8a -->|defined in| c71b26df_821f_59ac_c7ef_3b96fcbe0d5b
  style eced1d02_7caf_3dcf_3e0e_eccdb5936b8a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_retry.py lines 942–971

def test_tool_retry_deprecated_raise_behavior() -> None:
    """Test ToolRetryMiddleware with deprecated 'raise' forwards to 'error' behavior."""
    model = FakeToolCallingModel(
        tool_calls=[
            [ToolCall(name="failing_tool", args={"value": "test"}, id="1")],
            [],
        ]
    )

    with pytest.warns(DeprecationWarning, match="on_failure='raise' is deprecated"):
        retry = ToolRetryMiddleware(
            max_retries=2,
            initial_delay=0.01,
            jitter=False,
            on_failure="raise",  # type: ignore[arg-type]
        )

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

    # Should raise the ValueError from the tool (same as 'error')
    with pytest.raises(ValueError, match="Failed: test"):
        agent.invoke(
            {"messages": [HumanMessage("Use failing tool")]},
            {"configurable": {"thread_id": "test"}},
        )

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free