Home / Function/ test_async_non_emulated_tools_execute_normally() — langchain Function Reference

test_async_non_emulated_tools_execute_normally() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_emulator.py lines 483–517

    async def test_async_non_emulated_tools_execute_normally(self) -> None:
        """Test that tools not in tools_to_emulate execute normally in async mode."""
        agent_model = FakeModel(
            messages=cycle(
                [
                    AIMessage(
                        content="",
                        tool_calls=[
                            {"name": "calculator", "id": "1", "args": {"expression": "2+2"}}
                        ],
                    ),
                    AIMessage(content="The calculation is complete."),
                ]
            )
        )

        emulator_model = FakeEmulatorModel(responses=["Should not be used"])

        # Only emulate get_weather, not calculator
        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("Calculate 2+2")]})

        # Calculator should execute normally and return Result: 4
        tool_messages = [
            msg for msg in result["messages"] if hasattr(msg, "name") and msg.name == "calculator"
        ]
        assert len(tool_messages) > 0
        assert "Result: 4" in tool_messages[0].content

Domain

Subdomains

Frequently Asked Questions

What does test_async_non_emulated_tools_execute_normally() do?
test_async_non_emulated_tools_execute_normally() 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_non_emulated_tools_execute_normally() defined?
test_async_non_emulated_tools_execute_normally() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_emulator.py at line 483.

Analyze Your Own Codebase

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

Try Supermodel Free