test_tool_search() — langchain Function Reference
Architecture documentation for the test_tool_search() function in test_chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 3a5f3f74_d5f5_c742_63ae_34d6335862a2["test_tool_search()"] f27640dd_3870_5548_d153_f9504ae1021f["test_chat_models.py"] 3a5f3f74_d5f5_c742_63ae_34d6335862a2 -->|defined in| f27640dd_3870_5548_d153_f9504ae1021f style 3a5f3f74_d5f5_c742_63ae_34d6335862a2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/anthropic/tests/integration_tests/test_chat_models.py lines 2081–2147
def test_tool_search(output_version: str) -> None:
"""Test tool search with LangChain tools using extras parameter."""
@tool(parse_docstring=True, extras={"defer_loading": True})
def get_weather(location: str, unit: str = "fahrenheit") -> str:
"""Get the current weather for a location.
Args:
location: City name
unit: Temperature unit (celsius or fahrenheit)
"""
return f"The weather in {location} is sunny and 72°{unit[0].upper()}"
@tool(parse_docstring=True, extras={"defer_loading": True})
def search_files(query: str) -> str:
"""Search through files in the workspace.
Args:
query: Search query
"""
return f"Found 3 files matching '{query}'"
model = ChatAnthropic(
model="claude-opus-4-5-20251101", output_version=output_version
)
agent = create_agent( # type: ignore[var-annotated]
model,
tools=[
{
"type": "tool_search_tool_regex_20251119",
"name": "tool_search_tool_regex",
},
get_weather,
search_files,
],
)
# Test with actual API call
input_message = {
"role": "user",
"content": "What's the weather in San Francisco? Find and use a tool.",
}
result = agent.invoke({"messages": [input_message]})
first_response = result["messages"][1]
content_types = [block["type"] for block in first_response.content]
if output_version == "v0":
assert content_types == [
"text",
"server_tool_use",
"tool_search_tool_result",
"text",
"tool_use",
]
else:
# v1
assert content_types == [
"text",
"server_tool_call",
"server_tool_result",
"text",
"tool_call",
]
answer = result["messages"][-1]
assert not answer.tool_calls
assert answer.text
Domain
Subdomains
Source
Frequently Asked Questions
What does test_tool_search() do?
test_tool_search() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/integration_tests/test_chat_models.py.
Where is test_tool_search() defined?
test_tool_search() is defined in libs/partners/anthropic/tests/integration_tests/test_chat_models.py at line 2081.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free