Home / Function/ test_decorator_with_state_access() — langchain Function Reference

test_decorator_with_state_access() — langchain Function Reference

Architecture documentation for the test_decorator_with_state_access() function in test_wrap_model_call.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  d91321d0_ced4_d08c_3e4c_6da7763e2887["test_decorator_with_state_access()"]
  5a3c6db0_0302_046a_d217_22fb3d4e632e["TestWrapModelCallDecorator"]
  d91321d0_ced4_d08c_3e4c_6da7763e2887 -->|defined in| 5a3c6db0_0302_046a_d217_22fb3d4e632e
  style d91321d0_ced4_d08c_3e4c_6da7763e2887 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py lines 1133–1153

    def test_decorator_with_state_access(self) -> None:
        """Test decorator accessing agent state."""
        state_values = []

        @wrap_model_call
        def log_state(
            request: ModelRequest,
            handler: Callable[[ModelRequest], ModelResponse],
        ) -> ModelCallResult:
            state_values.append(request.state.get("messages"))
            return handler(request)

        model = GenericFakeChatModel(messages=iter([AIMessage(content="Response")]))
        agent = create_agent(model=model, middleware=[log_state])

        agent.invoke({"messages": [HumanMessage("Test")]})

        # State should contain the user message
        assert len(state_values) == 1
        assert len(state_values[0]) == 1
        assert state_values[0][0].content == "Test"

Domain

Subdomains

Frequently Asked Questions

What does test_decorator_with_state_access() do?
test_decorator_with_state_access() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py.
Where is test_decorator_with_state_access() defined?
test_decorator_with_state_access() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py at line 1133.

Analyze Your Own Codebase

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

Try Supermodel Free