Home / Class/ RetryOnceMiddleware Class — langchain Architecture

RetryOnceMiddleware Class — langchain Architecture

Architecture documentation for the RetryOnceMiddleware class in test_wrap_model_call.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  623f62c5_0ef6_d0ab_80fc_ef5c027c9dbb["RetryOnceMiddleware"]
  949c7cf4_56fe_f3b4_cd89_9631a7e9cb1e["AgentMiddleware"]
  623f62c5_0ef6_d0ab_80fc_ef5c027c9dbb -->|extends| 949c7cf4_56fe_f3b4_cd89_9631a7e9cb1e
  573473e5_eb93_a7d7_84ba_c975071c09af["test_wrap_model_call.py"]
  623f62c5_0ef6_d0ab_80fc_ef5c027c9dbb -->|defined in| 573473e5_eb93_a7d7_84ba_c975071c09af
  156aa6a1_c797_2484_93db_cc6c3c3c618c["__init__()"]
  623f62c5_0ef6_d0ab_80fc_ef5c027c9dbb -->|method| 156aa6a1_c797_2484_93db_cc6c3c3c618c
  ae988b45_661a_65f8_8ad7_a74e0c00c6cd["wrap_model_call()"]
  623f62c5_0ef6_d0ab_80fc_ef5c027c9dbb -->|method| ae988b45_661a_65f8_8ad7_a74e0c00c6cd

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py lines 128–142

        class RetryOnceMiddleware(AgentMiddleware):
            def __init__(self) -> None:
                super().__init__()
                self.retry_count = 0

            def wrap_model_call(
                self,
                request: ModelRequest,
                handler: Callable[[ModelRequest], ModelResponse],
            ) -> ModelCallResult:
                try:
                    return handler(request)
                except Exception:
                    self.retry_count += 1
                    return handler(request)

Extends

Frequently Asked Questions

What is the RetryOnceMiddleware class?
RetryOnceMiddleware is a class in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py.
Where is RetryOnceMiddleware defined?
RetryOnceMiddleware is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py at line 128.
What does RetryOnceMiddleware extend?
RetryOnceMiddleware extends AgentMiddleware.

Analyze Your Own Codebase

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

Try Supermodel Free