test_async_emulates_specified_tool_by_instance() — langchain Function Reference
Architecture documentation for the test_async_emulates_specified_tool_by_instance() function in test_tool_emulator.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 469df27e_dbb2_7ae8_b72f_e7e95ec844de["test_async_emulates_specified_tool_by_instance()"] b8b6edb5_5f70_2c98_97cd_e94de900fbeb["TestLLMToolEmulatorAsync"] 469df27e_dbb2_7ae8_b72f_e7e95ec844de -->|defined in| b8b6edb5_5f70_2c98_97cd_e94de900fbeb style 469df27e_dbb2_7ae8_b72f_e7e95ec844de fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_emulator.py lines 455–481
async def test_async_emulates_specified_tool_by_instance(self) -> None:
"""Test that tools specified by BaseTool instance are emulated in async mode."""
agent_model = FakeModel(
messages=cycle(
[
AIMessage(
content="",
tool_calls=[{"name": "search_web", "id": "1", "args": {"query": "Python"}}],
),
AIMessage(content="Search results retrieved."),
]
)
)
emulator_model = FakeEmulatorModel(responses=["Emulated: Python is a programming language"])
emulator = LLMToolEmulator(tools=[search_web], model=emulator_model)
agent = create_agent(
model=agent_model,
tools=[search_web, calculator],
middleware=[emulator],
)
result = await agent.ainvoke({"messages": [HumanMessage("Search for Python")]})
assert isinstance(result["messages"][-1], AIMessage)
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_async_emulates_specified_tool_by_instance() do?
test_async_emulates_specified_tool_by_instance() 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_emulates_specified_tool_by_instance() defined?
test_async_emulates_specified_tool_by_instance() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_emulator.py at line 455.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free