__run__() — anthropic-sdk-python Function Reference
Architecture documentation for the __run__() function in _beta_runner.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 98b55090_3b6f_2dd4_ca2d_6c52114d5a9e["__run__()"] 9149fa46_e498_7ba3_1b94_e0095e473ff9["BaseSyncToolRunner"] 98b55090_3b6f_2dd4_ca2d_6c52114d5a9e -->|defined in| 9149fa46_e498_7ba3_1b94_e0095e473ff9 21042fa5_2057_e026_e344_8ecf6abf02cc["_should_stop()"] 98b55090_3b6f_2dd4_ca2d_6c52114d5a9e -->|calls| 21042fa5_2057_e026_e344_8ecf6abf02cc 7a42b7b5_3b45_98bf_0780_6f0ec5133610["_handle_request()"] 98b55090_3b6f_2dd4_ca2d_6c52114d5a9e -->|calls| 7a42b7b5_3b45_98bf_0780_6f0ec5133610 b2a98d76_24b2_7388_d54b_d0f7084fdb5f["_get_last_message()"] 98b55090_3b6f_2dd4_ca2d_6c52114d5a9e -->|calls| b2a98d76_24b2_7388_d54b_d0f7084fdb5f fc3214ad_dd7a_b1a4_994d_95d55d1f3a68["_check_and_compact()"] 98b55090_3b6f_2dd4_ca2d_6c52114d5a9e -->|calls| fc3214ad_dd7a_b1a4_994d_95d55d1f3a68 b6f147a7_041c_a75b_75d3_8d273a48e4e5["generate_tool_call_response()"] 98b55090_3b6f_2dd4_ca2d_6c52114d5a9e -->|calls| b6f147a7_041c_a75b_75d3_8d273a48e4e5 4970c546_0fad_9c03_1498_9ae6f7952dcf["append_messages()"] 98b55090_3b6f_2dd4_ca2d_6c52114d5a9e -->|calls| 4970c546_0fad_9c03_1498_9ae6f7952dcf style 98b55090_3b6f_2dd4_ca2d_6c52114d5a9e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/anthropic/lib/tools/_beta_runner.py lines 242–262
def __run__(self) -> Iterator[RunnerItemT]:
while not self._should_stop():
with self._handle_request() as item:
yield item
message = self._get_last_message()
assert message is not None
self._iteration_count += 1
# If the compaction was performed, skip tool call generation this iteration
if not self._check_and_compact():
response = self.generate_tool_call_response()
if response is None:
log.debug("Tool call was not requested, exiting from tool runner loop.")
return
if not self._messages_modified:
self.append_messages(message, response)
self._messages_modified = False
self._cached_tool_call_response = None
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does __run__() do?
__run__() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/lib/tools/_beta_runner.py.
Where is __run__() defined?
__run__() is defined in src/anthropic/lib/tools/_beta_runner.py at line 242.
What does __run__() call?
__run__() calls 6 function(s): _check_and_compact, _get_last_message, _handle_request, _should_stop, append_messages, generate_tool_call_response.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free