tools_runner_search_tool.py — anthropic-sdk-python Source File
Architecture documentation for tools_runner_search_tool.py, a python file in the anthropic-sdk-python codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR fb1a4163_0002_aa33_791c_d193be58f7a1["tools_runner_search_tool.py"] 28b0c811_20f6_fc4a_4b48_7fb9e87bf7e5["json"] fb1a4163_0002_aa33_791c_d193be58f7a1 --> 28b0c811_20f6_fc4a_4b48_7fb9e87bf7e5 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"] fb1a4163_0002_aa33_791c_d193be58f7a1 --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875 37c05070_ca59_d596_7250_de9d1939227f["typing_extensions"] fb1a4163_0002_aa33_791c_d193be58f7a1 --> 37c05070_ca59_d596_7250_de9d1939227f a0b28eb3_d4e0_bb21_6a83_ba005c9793f4["rich"] fb1a4163_0002_aa33_791c_d193be58f7a1 --> a0b28eb3_d4e0_bb21_6a83_ba005c9793f4 d10c5377_2939_0f0b_cc44_8759393f2853["anthropic"] fb1a4163_0002_aa33_791c_d193be58f7a1 --> d10c5377_2939_0f0b_cc44_8759393f2853 401f8a6c_a177_4dcd_662b_ade2f5d17081["anthropic.lib.tools"] fb1a4163_0002_aa33_791c_d193be58f7a1 --> 401f8a6c_a177_4dcd_662b_ade2f5d17081 02abf1f6_b512_32df_c4f5_940df96192d8["anthropic.types.beta"] fb1a4163_0002_aa33_791c_d193be58f7a1 --> 02abf1f6_b512_32df_c4f5_940df96192d8 style fb1a4163_0002_aa33_791c_d193be58f7a1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import json
from typing import Any, List
from typing_extensions import Literal
import rich
from anthropic import Anthropic, beta_tool
from anthropic.lib.tools import BetaFunctionTool, BetaFunctionToolResultType
from anthropic.types.beta import BetaToolReferenceBlockParam
client = Anthropic()
@beta_tool(defer_loading=True)
def get_weather(location: str, units: Literal["c", "f"]) -> str:
"""Lookup the weather for a given city in either celsius or fahrenheit
Args:
location: The city and state, e.g. San Francisco, CA
units: Unit for the output, either 'c' for celsius or 'f' for fahrenheit
Returns:
A dictionary containing the location, temperature, and weather condition.
"""
# Simulate a weather API call
print(f"Fetching weather for {location} in {units}")
# Here you would typically make an API call to a weather service
# For demonstration, we return a mock response
if units == "c":
return json.dumps(
{
"location": location,
"temperature": "20°C",
"condition": "Sunny",
}
)
else:
return json.dumps(
{
"location": location,
"temperature": "68°F",
"condition": "Sunny",
}
)
def make_tool_searcher(tools: List[BetaFunctionTool[Any]]) -> BetaFunctionTool[Any]:
"""Returns a tool that Claude can use to search through all available tools"""
@beta_tool
def search_available_tools(*, keyword: str) -> BetaFunctionToolResultType:
"""Search for useful tools using a query string"""
results: list[BetaToolReferenceBlockParam] = []
for tool in tools:
if keyword in json.dumps(tool.to_dict()):
results.append({"type": "tool_reference", "tool_name": tool.name})
return results
return search_available_tools
def main() -> None:
tools: list[BetaFunctionTool[Any]] = [
get_weather,
# ... many more tools
]
runner = client.beta.messages.tool_runner(
max_tokens=1024,
model="claude-sonnet-4-5-20250929",
tools=[*tools, make_tool_searcher(tools)],
messages=[{"role": "user", "content": "What is the weather in SF?"}],
betas=["tool-search-tool-2025-10-19"],
)
for message in runner:
rich.print(message)
main()
Domain
Subdomains
Functions
Dependencies
- anthropic
- anthropic.lib.tools
- anthropic.types.beta
- json
- rich
- typing
- typing_extensions
Source
Frequently Asked Questions
What does tools_runner_search_tool.py do?
tools_runner_search_tool.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, SyncAPI subdomain.
What functions are defined in tools_runner_search_tool.py?
tools_runner_search_tool.py defines 3 function(s): get_weather, main, make_tool_searcher.
What does tools_runner_search_tool.py depend on?
tools_runner_search_tool.py imports 7 module(s): anthropic, anthropic.lib.tools, anthropic.types.beta, json, rich, typing, typing_extensions.
Where is tools_runner_search_tool.py in the architecture?
tools_runner_search_tool.py is located at examples/tools_runner_search_tool.py (domain: AnthropicClient, subdomain: SyncAPI, directory: examples).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free