test_conditional_dynamic_tool() — langchain Function Reference
Architecture documentation for the test_conditional_dynamic_tool() function in test_dynamic_tools.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD ae47d32e_0287_f9cf_dc6d_c7a47d02f8c3["test_conditional_dynamic_tool()"] ed3bf1bf_abaf_832a_a548_adfcdbed05b3["test_dynamic_tools.py"] ae47d32e_0287_f9cf_dc6d_c7a47d02f8c3 -->|defined in| ed3bf1bf_abaf_832a_a548_adfcdbed05b3 fe27ad32_78c6_de3f_c030_9c2e48e1cd22["invoke_agent()"] ae47d32e_0287_f9cf_dc6d_c7a47d02f8c3 -->|calls| fe27ad32_78c6_de3f_c030_9c2e48e1cd22 718649e7_ca41_a633_085d_48f52a118df2["get_tool_messages()"] ae47d32e_0287_f9cf_dc6d_c7a47d02f8c3 -->|calls| 718649e7_ca41_a633_085d_48f52a118df2 style ae47d32e_0287_f9cf_dc6d_c7a47d02f8c3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_dynamic_tools.py lines 322–343
async def test_conditional_dynamic_tool(*, use_async: bool) -> None:
"""Test that dynamic tools can be conditionally added based on state."""
model = FakeToolCallingModel(
tool_calls=[
[ToolCall(name="another_dynamic_tool", args={"x": 10, "y": 20}, id="1")],
[],
]
)
agent = create_agent(
model=model,
tools=[static_tool],
middleware=[ConditionalDynamicToolMiddleware()],
checkpointer=InMemorySaver(),
)
result = await invoke_agent(agent, "I need a calculator to add numbers", use_async=use_async)
tool_messages = get_tool_messages(result)
assert len(tool_messages) == 1
assert tool_messages[0].name == "another_dynamic_tool"
assert "Sum: 30" in tool_messages[0].content
Domain
Subdomains
Source
Frequently Asked Questions
What does test_conditional_dynamic_tool() do?
test_conditional_dynamic_tool() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_dynamic_tools.py.
Where is test_conditional_dynamic_tool() defined?
test_conditional_dynamic_tool() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_dynamic_tools.py at line 322.
What does test_conditional_dynamic_tool() call?
test_conditional_dynamic_tool() calls 2 function(s): get_tool_messages, invoke_agent.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free