Home / Function/ test_mixed_emulated_and_real_tools() — langchain Function Reference

test_mixed_emulated_and_real_tools() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  2e921c55_7fd8_f39a_b7d5_28c0b10cd6e3["test_mixed_emulated_and_real_tools()"]
  9b3f64f0_79d5_a9bf_170e_4a7bc7691e18["TestLLMToolEmulatorMultipleTools"]
  2e921c55_7fd8_f39a_b7d5_28c0b10cd6e3 -->|defined in| 9b3f64f0_79d5_a9bf_170e_4a7bc7691e18
  style 2e921c55_7fd8_f39a_b7d5_28c0b10cd6e3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_emulator.py lines 324–360

    def test_mixed_emulated_and_real_tools(self) -> None:
        """Test that some tools can be emulated while others execute normally."""
        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 = agent.invoke({"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_mixed_emulated_and_real_tools() do?
test_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_mixed_emulated_and_real_tools() defined?
test_mixed_emulated_and_real_tools() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_emulator.py at line 324.

Analyze Your Own Codebase

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

Try Supermodel Free