Home / Function/ test_tool_retry_deprecated_return_message_behavior() — langchain Function Reference

test_tool_retry_deprecated_return_message_behavior() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_retry.py lines 974–1011

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

    # Use string concatenation to avoid batch replace affecting test code
    deprecated_value = "return" + "_message"
    with pytest.warns(DeprecationWarning, match="on_failure='return_message' is deprecated"):
        retry = ToolRetryMiddleware(
            max_retries=2,
            initial_delay=0.01,
            jitter=False,
            on_failure=deprecated_value,  # type: ignore[arg-type]
        )

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

    result = agent.invoke(
        {"messages": [HumanMessage("Use failing tool")]},
        {"configurable": {"thread_id": "test"}},
    )

    tool_messages = [m for m in result["messages"] if isinstance(m, ToolMessage)]
    assert len(tool_messages) == 1
    # Should contain error message (same as 'continue')
    assert "failing_tool" in tool_messages[0].content
    assert "3 attempts" in tool_messages[0].content
    assert "ValueError" in tool_messages[0].content
    assert tool_messages[0].status == "error"

Domain

Subdomains

Frequently Asked Questions

What does test_tool_retry_deprecated_return_message_behavior() do?
test_tool_retry_deprecated_return_message_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_return_message_behavior() defined?
test_tool_retry_deprecated_return_message_behavior() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_retry.py at line 974.

Analyze Your Own Codebase

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

Try Supermodel Free