test_tool_call_caching() — anthropic-sdk-python Function Reference
Architecture documentation for the test_tool_call_caching() function in test_runners.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD eb9121ce_90c5_9e50_25e6_4cd4f45e879d["test_tool_call_caching()"] 6847e1ae_03a4_3e19_19ff_ea808e74d94c["TestSyncRunTools"] eb9121ce_90c5_9e50_25e6_4cd4f45e879d -->|defined in| 6847e1ae_03a4_3e19_19ff_ea808e74d94c be8a7f3a_5951_1f73_7331_3ad05c999ecf["_get_weather()"] eb9121ce_90c5_9e50_25e6_4cd4f45e879d -->|calls| be8a7f3a_5951_1f73_7331_3ad05c999ecf style eb9121ce_90c5_9e50_25e6_4cd4f45e879d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/lib/tools/test_runners.py lines 225–265
def test_tool_call_caching(self, client: Anthropic, respx_mock: MockRouter) -> None:
called = None
@beta_tool
def get_weather(location: str, units: Literal["c", "f"]) -> BetaFunctionToolResultType:
nonlocal called
"""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.
"""
if called is None:
called = True
return json.dumps(_get_weather(location, units))
raise RuntimeError("This tool should not be called again")
def tool_runner(client: Anthropic) -> None:
runner = client.beta.messages.tool_runner(
model="claude-haiku-4-5",
messages=[{"role": "user", "content": "What's the weather in SF in Celsius?"}],
tools=[get_weather],
max_tokens=1024,
)
for _ in runner:
response1 = runner.generate_tool_call_response()
response2 = runner.generate_tool_call_response()
if response1 is not None:
assert response1 is response2
make_snapshot_request(
tool_runner,
content_snapshot=snapshots["tool_call"]["responses"],
path="/v1/messages",
mock_client=client,
respx_mock=respx_mock,
)
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does test_tool_call_caching() do?
test_tool_call_caching() is a function in the anthropic-sdk-python codebase, defined in tests/lib/tools/test_runners.py.
Where is test_tool_call_caching() defined?
test_tool_call_caching() is defined in tests/lib/tools/test_runners.py at line 225.
What does test_tool_call_caching() call?
test_tool_call_caching() calls 1 function(s): _get_weather.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free