CountingMiddleware Class — langchain Architecture
Architecture documentation for the CountingMiddleware class in test_wrap_model_call.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 4c3830c7_6e18_e2ea_fa81_45f98fb163b9["CountingMiddleware"] 949c7cf4_56fe_f3b4_cd89_9631a7e9cb1e["AgentMiddleware"] 4c3830c7_6e18_e2ea_fa81_45f98fb163b9 -->|extends| 949c7cf4_56fe_f3b4_cd89_9631a7e9cb1e 573473e5_eb93_a7d7_84ba_c975071c09af["test_wrap_model_call.py"] 4c3830c7_6e18_e2ea_fa81_45f98fb163b9 -->|defined in| 573473e5_eb93_a7d7_84ba_c975071c09af 7a32a409_d22e_ce7c_b57a_112d1f24dbc5["__init__()"] 4c3830c7_6e18_e2ea_fa81_45f98fb163b9 -->|method| 7a32a409_d22e_ce7c_b57a_112d1f24dbc5 bd88e38f_c3b8_b3d7_5876_3db06f609448["wrap_model_call()"] 4c3830c7_6e18_e2ea_fa81_45f98fb163b9 -->|method| bd88e38f_c3b8_b3d7_5876_3db06f609448
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py lines 84–95
class CountingMiddleware(AgentMiddleware):
def __init__(self) -> None:
super().__init__()
self.call_count = 0
def wrap_model_call(
self,
request: ModelRequest,
handler: Callable[[ModelRequest], ModelResponse],
) -> ModelCallResult:
self.call_count += 1
return handler(request)
Extends
Source
Frequently Asked Questions
What is the CountingMiddleware class?
CountingMiddleware 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 CountingMiddleware defined?
CountingMiddleware is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py at line 84.
What does CountingMiddleware extend?
CountingMiddleware extends AgentMiddleware.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free