Home / Function/ test_async_mixed_emulated_and_real_tools() — langchain Function Reference

test_async_mixed_emulated_and_real_tools() — langchain Function Reference

Architecture documentation for the test_async_mixed_emulated_and_real_tools() function in test_tool_emulator.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  3e2a35a1_3f58_b0ee_e045_e4b34f4e1df1["test_async_mixed_emulated_and_real_tools()"]
  b8b6edb5_5f70_2c98_97cd_e94de900fbeb["TestLLMToolEmulatorAsync"]
  3e2a35a1_3f58_b0ee_e045_e4b34f4e1df1 -->|defined in| b8b6edb5_5f70_2c98_97cd_e94de900fbeb
  style 3e2a35a1_3f58_b0ee_e045_e4b34f4e1df1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_emulator.py lines 587–623

    async def test_async_mixed_emulated_and_real_tools(self) -> None:
        """Test that some tools can be emulated while others execute normally in async mode."""
        agent_model = FakeModel(
            messages=cycle(
                [
                    AIMessage(
                        content="",
                        tool_calls=[
                            {"name": "get_weather", "id": "1", "args": {"location": "NYC"}},
                            {"name": "calculator", "id": "2", "args": {"expression": "10*2"}},
                        ],
                    ),
                    AIMessage(content="Both completed."),
                ]
            )
        )

        emulator_model = FakeEmulatorModel(responses=["Emulated: 65°F in NYC"])

        # Only emulate get_weather
        emulator = LLMToolEmulator(tools=["get_weather"], model=emulator_model)

        agent = create_agent(
            model=agent_model,
            tools=[get_weather, calculator],
            middleware=[emulator],
        )

        result = await agent.ainvoke({"messages": [HumanMessage("Weather and calculate")]})

        tool_messages = [msg for msg in result["messages"] if hasattr(msg, "name")]
        assert len(tool_messages) >= 2

        # Calculator should have real result
        calc_messages = [msg for msg in tool_messages if msg.name == "calculator"]
        assert len(calc_messages) > 0
        assert "Result: 20" in calc_messages[0].content

Domain

Subdomains

Frequently Asked Questions

What does test_async_mixed_emulated_and_real_tools() do?
test_async_mixed_emulated_and_real_tools() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_emulator.py.
Where is test_async_mixed_emulated_and_real_tools() defined?
test_async_mixed_emulated_and_real_tools() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_emulator.py at line 587.

Analyze Your Own Codebase

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

Try Supermodel Free