Home / Class/ TemporaryFailureTool Class — langchain Architecture

TemporaryFailureTool Class — langchain Architecture

Architecture documentation for the TemporaryFailureTool class in test_tool_retry.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  d303b4e8_4b2c_6f16_ce41_c54b9e9fbbe0["TemporaryFailureTool"]
  c71b26df_821f_59ac_c7ef_3b96fcbe0d5b["test_tool_retry.py"]
  d303b4e8_4b2c_6f16_ce41_c54b9e9fbbe0 -->|defined in| c71b26df_821f_59ac_c7ef_3b96fcbe0d5b
  3a9532c2_91a6_ebd0_49ef_86482dab0f94["__init__()"]
  d303b4e8_4b2c_6f16_ce41_c54b9e9fbbe0 -->|method| 3a9532c2_91a6_ebd0_49ef_86482dab0f94
  3d016a54_d4ea_ddef_e2d2_8a841962e009["__call__()"]
  d303b4e8_4b2c_6f16_ce41_c54b9e9fbbe0 -->|method| 3d016a54_d4ea_ddef_e2d2_8a841962e009

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_retry.py lines 34–62

class TemporaryFailureTool:
    """Tool that fails a certain number of times before succeeding."""

    def __init__(self, fail_count: int):
        """Initialize with the number of times to fail.

        Args:
            fail_count: Number of times to fail before succeeding.
        """
        self.fail_count = fail_count
        self.attempt = 0

    def __call__(self, value: str) -> str:
        """Execute the tool.

        Args:
            value: Input string.

        Returns:
            Success message if attempt >= fail_count.

        Raises:
            ValueError: If attempt < fail_count.
        """
        self.attempt += 1
        if self.attempt <= self.fail_count:
            msg = f"Temporary failure {self.attempt}"
            raise ValueError(msg)
        return f"Success after {self.attempt} attempts: {value}"

Frequently Asked Questions

What is the TemporaryFailureTool class?
TemporaryFailureTool is a class in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_retry.py.
Where is TemporaryFailureTool defined?
TemporaryFailureTool is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_retry.py at line 34.

Analyze Your Own Codebase

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

Try Supermodel Free