Follow Discord
Sweep 22 Oct 2026 · 04:32Z Build v2.1.308 527 read Stable v2.1.308 Latest v2.1.308 Next v2.1.308 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

Process results programmatically changedagents-and-tools/tool-use/programmatic-tool-calling

Nearest release: v2.1.308, published 2 hours after 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+8added
Lines−8removed
From line 376 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits14to this page, all time

The whole hunk

from line 376, old and new numbered
/
lines
from line 376
376376This approach is particularly useful for:
377377 
378378* **Large data processing:** Filter or aggregate tool results before they reach Claude's context.
379* **Multistep workflows:** Save tokens and latency by calling tools serially or in a loop without sampling Claude in-between tool calls.
379* **Multistep workflows:** Save tokens and latency by calling tools serially or in a loop without sampling Claude between tool calls.
380380* **Conditional logic:** Make decisions based on intermediate tool results.
381381 
382382<Note>
from line 422
422422 
423423**Direct call (traditional tool use):**
424424 
425```json
425```text wrap
426426{
427427 "type": "tool_use",
428428 "id": "toolu_abc123",
from line 434
434434 
435435**Programmatic call:**
436436 
437```json
437```text wrap
438438{
439439 "type": "tool_use",
440440 "id": "toolu_xyz789",
from line 480
480480 
481481Claude writes code that calls your tool. The API pauses and returns:
482482 
483```json Output
483```text Output
484484{
485485 "role": "assistant",
486486 "content": [
from line 1160
11601160 
11611161Once the code execution completes, Claude provides the final response:
11621162 
1163```json Output
1163```text Output
11641164{
11651165 "content": [
11661166 {
from line 1249
12491249 
12501250When code execution calls a tool:
12511251 
1252```json
1252```text wrap
12531253{
12541254 "type": "tool_use",
12551255 "id": "toolu_abc123",
from line 1283
12831283 
12841284When all tool calls are satisfied and code completes:
12851285 
1286```json
1286```text
12871287{
12881288 "type": "code_execution_tool_result",
12891289 "tool_use_id": "srvtoolu_xyz789",
from line 1310
13101310 
13111311If your tool result doesn't arrive within about 4 minutes, the pending call raises a `TimeoutError` inside Claude's running code. Claude receives the error in `stderr` and typically retries the call:
13121312 
1313```json
1313```text
13141314{
13151315 "type": "code_execution_tool_result",
13161316 "tool_use_id": "srvtoolu_abc123",
Feedback