test_search_result_tool_message() — langchain Function Reference
Architecture documentation for the test_search_result_tool_message() function in test_chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD ae1b93cb_be65_cab1_b159_d178ebb7c6a1["test_search_result_tool_message()"] f27640dd_3870_5548_d153_f9504ae1021f["test_chat_models.py"] ae1b93cb_be65_cab1_b159_d178ebb7c6a1 -->|defined in| f27640dd_3870_5548_d153_f9504ae1021f style ae1b93cb_be65_cab1_b159_d178ebb7c6a1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/anthropic/tests/integration_tests/test_chat_models.py lines 1925–1980
def test_search_result_tool_message() -> None:
"""Test that we can pass a search result tool message to the model."""
llm = ChatAnthropic(
model=MODEL_NAME, # type: ignore[call-arg]
)
@tool
def retrieval_tool(query: str) -> list[dict]:
"""Retrieve information from a knowledge base."""
return [
{
"type": "search_result",
"title": "Leave policy",
"source": "HR Leave Policy 2025",
"citations": {"enabled": True},
"content": [
{
"type": "text",
"text": (
"To request vacation days, submit a leave request form "
"through the HR portal. Approval will be sent by email."
),
},
],
},
]
tool_call = {
"type": "tool_call",
"name": "retrieval_tool",
"args": {"query": "vacation days request process"},
"id": "toolu_abc123",
}
tool_message = retrieval_tool.invoke(tool_call)
assert isinstance(tool_message, ToolMessage)
assert isinstance(tool_message.content, list)
messages = [
HumanMessage("How do I request vacation days?"),
AIMessage(
[{"type": "text", "text": "Let me look that up for you."}],
tool_calls=[tool_call],
),
tool_message,
]
result = llm.invoke(messages)
assert isinstance(result, AIMessage)
assert isinstance(result.content, list)
assert any("citations" in block for block in result.content)
assert (
_convert_from_v1_to_anthropic(result.content_blocks, [], "anthropic")
== result.content
)
Domain
Subdomains
Source
Frequently Asked Questions
What does test_search_result_tool_message() do?
test_search_result_tool_message() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/integration_tests/test_chat_models.py.
Where is test_search_result_tool_message() defined?
test_search_result_tool_message() is defined in libs/partners/anthropic/tests/integration_tests/test_chat_models.py at line 1925.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free