test_tool_search_result_formatting() — langchain Function Reference
Architecture documentation for the test_tool_search_result_formatting() function in test_chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 281e25d3_c26f_61ed_b013_b769ade470aa["test_tool_search_result_formatting()"] 18428dc5_a41b_90c6_88ad_615296ee3311["test_chat_models.py"] 281e25d3_c26f_61ed_b013_b769ade470aa -->|defined in| 18428dc5_a41b_90c6_88ad_615296ee3311 style 281e25d3_c26f_61ed_b013_b769ade470aa fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/anthropic/tests/unit_tests/test_chat_models.py lines 1923–1968
def test_tool_search_result_formatting() -> None:
"""Test that `tool_result` blocks with `tool_reference` are handled correctly."""
# Tool search result with tool_reference blocks
messages = [
HumanMessage("What tools can help with weather?"), # type: ignore[misc]
AIMessage( # type: ignore[misc]
[
{
"type": "server_tool_use",
"id": "srvtoolu_123",
"name": "tool_search_tool_regex",
"input": {"query": "weather"},
},
{
"type": "tool_result",
"tool_use_id": "srvtoolu_123",
"content": [
{"type": "tool_reference", "tool_name": "get_weather"},
{"type": "tool_reference", "tool_name": "weather_forecast"},
],
},
],
),
]
_, formatted = _format_messages(messages)
# Verify the tool_result block is preserved correctly
assistant_msg = formatted[1]
assert assistant_msg["role"] == "assistant"
# Find the tool_result block
tool_result_block = None
for block in assistant_msg["content"]:
if isinstance(block, dict) and block.get("type") == "tool_result":
tool_result_block = block
break
assert tool_result_block is not None
assert tool_result_block["tool_use_id"] == "srvtoolu_123"
assert isinstance(tool_result_block["content"], list)
assert len(tool_result_block["content"]) == 2
assert tool_result_block["content"][0]["type"] == "tool_reference"
assert tool_result_block["content"][0]["tool_name"] == "get_weather"
assert tool_result_block["content"][1]["type"] == "tool_reference"
assert tool_result_block["content"][1]["tool_name"] == "weather_forecast"
Domain
Subdomains
Source
Frequently Asked Questions
What does test_tool_search_result_formatting() do?
test_tool_search_result_formatting() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py.
Where is test_tool_search_result_formatting() defined?
test_tool_search_result_formatting() is defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py at line 1923.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free