Home / Function/ test_state_schema_async() — langchain Function Reference

test_state_schema_async() — langchain Function Reference

Architecture documentation for the test_state_schema_async() function in test_state_schema.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  839268f4_7dba_d1c1_3ed6_4a5da464ef88["test_state_schema_async()"]
  3d4a3f09_0839_f785_dcfd_f1e7b13e3204["test_state_schema.py"]
  839268f4_7dba_d1c1_3ed6_4a5da464ef88 -->|defined in| 3d4a3f09_0839_f785_dcfd_f1e7b13e3204
  style 839268f4_7dba_d1c1_3ed6_4a5da464ef88 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/test_state_schema.py lines 171–198

async def test_state_schema_async() -> None:
    """Test that state_schema works with async agents."""

    class AsyncState(AgentState[Any]):
        async_field: str

    @tool
    async def async_tool(x: int) -> str:
        """Async tool."""
        return f"Async: {x}"

    agent = create_agent(
        model=FakeToolCallingModel(
            tool_calls=[[{"args": {"x": 99}, "id": "call_1", "name": "async_tool"}], []]
        ),
        tools=[async_tool],
        state_schema=AsyncState,
    )

    result = await agent.ainvoke(
        {
            "messages": [HumanMessage("Test async")],
            "async_field": "async_value",
        }
    )

    assert result["async_field"] == "async_value"
    assert "Async: 99" in result["messages"][2].content

Domain

Subdomains

Frequently Asked Questions

What does test_state_schema_async() do?
test_state_schema_async() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/test_state_schema.py.
Where is test_state_schema_async() defined?
test_state_schema_async() is defined in libs/langchain_v1/tests/unit_tests/agents/test_state_schema.py at line 171.

Analyze Your Own Codebase

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

Try Supermodel Free