StateAwareMiddleware Class — langchain Architecture
Architecture documentation for the StateAwareMiddleware class in test_wrap_model_call.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 1c713b28_c405_b4b4_e73e_f49544f37de1["StateAwareMiddleware"] 949c7cf4_56fe_f3b4_cd89_9631a7e9cb1e["AgentMiddleware"] 1c713b28_c405_b4b4_e73e_f49544f37de1 -->|extends| 949c7cf4_56fe_f3b4_cd89_9631a7e9cb1e 573473e5_eb93_a7d7_84ba_c975071c09af["test_wrap_model_call.py"] 1c713b28_c405_b4b4_e73e_f49544f37de1 -->|defined in| 573473e5_eb93_a7d7_84ba_c975071c09af 8ea40d9c_353d_7d8d_8aa1_ad3c51e50978["wrap_model_call()"] 1c713b28_c405_b4b4_e73e_f49544f37de1 -->|method| 8ea40d9c_353d_7d8d_8aa1_ad3c51e50978
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py lines 611–623
class StateAwareMiddleware(AgentMiddleware):
def wrap_model_call(
self,
request: ModelRequest,
handler: Callable[[ModelRequest], ModelResponse],
) -> ModelCallResult:
# Access state from request
state_values.append(
{
"messages_count": len(request.state.get("messages", [])),
}
)
return handler(request)
Extends
Source
Frequently Asked Questions
What is the StateAwareMiddleware class?
StateAwareMiddleware 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 StateAwareMiddleware defined?
StateAwareMiddleware is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py at line 611.
What does StateAwareMiddleware extend?
StateAwareMiddleware extends AgentMiddleware.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free