Home / Function/ test_emulates_specified_tool_by_name() — langchain Function Reference

test_emulates_specified_tool_by_name() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  9a30a8a1_ce8b_02ae_b044_b6c6300e2877["test_emulates_specified_tool_by_name()"]
  f4edbff2_7ddf_8a09_14d8_c5faf6609d38["TestLLMToolEmulatorBasic"]
  9a30a8a1_ce8b_02ae_b044_b6c6300e2877 -->|defined in| f4edbff2_7ddf_8a09_14d8_c5faf6609d38
  style 9a30a8a1_ce8b_02ae_b044_b6c6300e2877 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_emulator.py lines 121–152

    def test_emulates_specified_tool_by_name(self) -> None:
        """Test that tools specified by name are emulated."""
        # Model that will call the tool
        agent_model = FakeModel(
            messages=cycle(
                [
                    AIMessage(
                        content="",
                        tool_calls=[
                            {"name": "get_weather", "id": "1", "args": {"location": "Paris"}}
                        ],
                    ),
                    AIMessage(content="The weather has been retrieved."),
                ]
            )
        )

        # Model that emulates tool responses
        emulator_model = FakeEmulatorModel(responses=["Emulated: 72°F, sunny in Paris"])

        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("What's the weather in Paris?")]})

        # Should complete without raising NotImplementedError
        assert isinstance(result["messages"][-1], AIMessage)

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free