TestLLMToolEmulatorModelConfiguration Class — langchain Architecture
Architecture documentation for the TestLLMToolEmulatorModelConfiguration class in test_tool_emulator.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD b7251e9a_e972_0104_74b3_75fbbecbaa7b["TestLLMToolEmulatorModelConfiguration"] de5a7878_b3fe_95d7_2575_7f534546dc1e["AIMessage"] b7251e9a_e972_0104_74b3_75fbbecbaa7b -->|extends| de5a7878_b3fe_95d7_2575_7f534546dc1e 5b00cf78_0f18_c9ad_fc5f_85cc0378daf1["test_tool_emulator.py"] b7251e9a_e972_0104_74b3_75fbbecbaa7b -->|defined in| 5b00cf78_0f18_c9ad_fc5f_85cc0378daf1 0ef94459_a72c_5643_9fda_4a7f707cad94["test_custom_model_string()"] b7251e9a_e972_0104_74b3_75fbbecbaa7b -->|method| 0ef94459_a72c_5643_9fda_4a7f707cad94 286d6868_28ee_bf52_fa3f_4a97ef6da38f["test_custom_model_instance()"] b7251e9a_e972_0104_74b3_75fbbecbaa7b -->|method| 286d6868_28ee_bf52_fa3f_4a97ef6da38f 64be2011_c59b_541f_c8bd_1a931b36201a["test_default_model_used_when_none()"] b7251e9a_e972_0104_74b3_75fbbecbaa7b -->|method| 64be2011_c59b_541f_c8bd_1a931b36201a
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_emulator.py lines 363–418
class TestLLMToolEmulatorModelConfiguration:
"""Test custom model configuration for emulation."""
def test_custom_model_string(self) -> None:
"""Test passing a model string for emulation."""
# Just test that initialization works - don't require anthropic package
try:
emulator = LLMToolEmulator(
tools=["get_weather"], model="anthropic:claude-sonnet-4-5-20250929"
)
assert emulator.model is not None
assert "get_weather" in emulator.tools_to_emulate
except ImportError:
# If anthropic isn't installed, that's fine for this unit test
pass
def test_custom_model_instance(self) -> None:
"""Test passing a BaseChatModel instance for emulation."""
agent_model = FakeModel(
messages=cycle(
[
AIMessage(
content="",
tool_calls=[{"name": "search_web", "id": "1", "args": {"query": "test"}}],
),
AIMessage(content="Done."),
]
)
)
custom_emulator_model = FakeEmulatorModel(responses=["Custom emulated response"])
emulator = LLMToolEmulator(tools=["search_web"], model=custom_emulator_model)
agent = create_agent(
model=agent_model,
tools=[search_web],
middleware=[emulator],
)
result = agent.invoke({"messages": [HumanMessage("Search for test")]})
# Should use the custom model for emulation
assert isinstance(result["messages"][-1], AIMessage)
def test_default_model_used_when_none(self) -> None:
"""Test that default model is used when model=None."""
# Just test that initialization doesn't fail - don't require anthropic package
# The actual default model requires langchain_anthropic which may not be installed
try:
emulator = LLMToolEmulator(tools=["get_weather"], model=None)
assert emulator.model is not None
except ImportError:
# If anthropic isn't installed, that's fine for this unit test
# The integration tests will verify the full functionality
pass
Defined In
Extends
Source
Frequently Asked Questions
What is the TestLLMToolEmulatorModelConfiguration class?
TestLLMToolEmulatorModelConfiguration is a class in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_emulator.py.
Where is TestLLMToolEmulatorModelConfiguration defined?
TestLLMToolEmulatorModelConfiguration is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_emulator.py at line 363.
What does TestLLMToolEmulatorModelConfiguration extend?
TestLLMToolEmulatorModelConfiguration extends AIMessage.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free