Follow Discord
Sweep 02 Oct 2026 · 18:55Z Build v2.1.288 509 read Stable v2.1.285 Latest v2.1.288 Next v2.1.288 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

Log at info level changedagents-and-tools/tool-use/tool-runner

Nearest release: v2.1.285, published 2 hours before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Recorded here
Lines+6added
Lines−6removed
From line 23 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits11to this page, all time

The whole hunk

from line 23, old and new numbered
/
lines
from line 23
2323 
2424Depending on the SDK's tool signature, a tool returns its result as a string or as content blocks (text, image, or document blocks), so a tool can return multimodal results. A returned string becomes a single text content block. To return structured data, such as a JSON object or a number, encode it as a string first.
2525 
26<Tabs>
26<Tabs exclude="shell">
2727 <Tab title="Python">
2828 Use the `@beta_tool` decorator to define tools with type hints and docstrings.
2929 
from line 593
593593 
594594If you don't need intermediate messages, you can get the final message directly:
595595 
596<Tabs>
596<Tabs exclude="shell">
597597 <Tab title="Python">
598598 Use `runner.until_done()` to get the final message.
599599 
from line 823
823823 
824824When you take over for an iteration, the runner does not append the assistant message or tool results from that turn. You become responsible for keeping the conversation valid: append the assistant message and a tool result yourself (if you want the turn to count), modify state conditionally so the loop can still exit when there are no tool calls, and pass `max_iterations` (csharp, java, php: `maxIterations`; go: `MaxIterations`) to bound the loop. All seven SDKs support `max_iterations` (csharp, java, php: `maxIterations`; go: `MaxIterations`).
825825 
826<Tabs>
826<Tabs exclude="shell">
827827 <Tab title="Python">
828828 Use `generate_tool_call_response()` to inspect or compute the tool result. Calling `append_messages()` inside the loop tells the runner you're managing history yourself, so include the assistant message and tool result in what you append.
829829 
from line 1130
11301130 
11311131In the Python and TypeScript SDKs, use the tool response method (`generate_tool_call_response()` in Python, `generateToolResponse()` in TypeScript) to intercept tool results and check for errors before they're sent to Claude. The other SDKs don't expose that hook. Their tabs describe the closest alternative:
11321132 
1133<Tabs>
1133<Tabs exclude="shell">
11341134 <Tab title="Python">
11351135 ```python
11361136 client = anthropic.Anthropic()
from line 1307
13071307 
13081308In the Python and TypeScript SDKs, use the tool response method to get the tool result, then modify it before the runner proceeds. Whether you explicitly append the modified result or mutate it in place depends on the SDK. See the code comments in each tab.
13091309 
1310<Tabs>
1310<Tabs exclude="shell">
13111311 <Tab title="Python">
13121312 ```python
13131313 client = anthropic.Anthropic()
from line 1535
15351535 
15361536Enable streaming to process each turn's response incrementally. Each iteration yields a stream object that you can iterate for events.
15371537 
1538<Tabs>
1538<Tabs exclude="shell">
15391539 <Tab title="Python">
15401540 Set `stream=True` and use `get_final_message()` to get the accumulated message.
15411541 
Feedback