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.286, published an hour 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+61added
Lines−5removed
From line 1,106 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 1106, old and new numbered
/
lines
from line 1106
11061106 
11071107### Automatic context management
11081108 
1109For long-running agentic tasks, the TypeScript and Ruby tool runners support automatic [compaction](https://platform.claude.com/docs/en/build-with-claude/context-editing#client-side-compaction-sdk), which generates summaries when token usage exceeds a threshold so the conversation can continue beyond context window limits. Both SDKs have deprecated this client-side option in favor of [server-side compaction](https://platform.claude.com/docs/en/build-with-claude/compaction-threshold), which works with every SDK's tool runner through the `context_management` request parameter. The Python SDK (v1.0 and later) and the Go, Java, C#, and PHP tool runners don't include client-side compaction. The Python, TypeScript, C#, Go, Java, PHP, and Ruby tool runners have a `compact_before_next_turn()` (typescript, java, php: `compactBeforeNextTurn()`; csharp, go: `CompactBeforeNextTurn()`) helper for on-demand compaction. See [Compact in a loop](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand#compact-in-a-loop). Use it or a `context_management` compaction edit on a runner, not both.
1109For long-running agentic tasks, the TypeScript and Ruby tool runners support automatic [compaction](https://platform.claude.com/docs/en/build-with-claude/context-editing#client-side-compaction-sdk), which generates summaries when token usage exceeds a threshold so the conversation can continue beyond context window limits. Both SDKs have deprecated this client-side option in favor of [server-side compaction](https://platform.claude.com/docs/en/build-with-claude/compaction-threshold), which works with every SDK's tool runner through the `context_management` request parameter. The Python SDK (v1.0 and later) and the Go, Java, C#, and PHP tool runners don't include client-side compaction. The tool runner has a `compact_before_next_turn()` (typescript, java, php: `compactBeforeNextTurn()`; csharp, go: `CompactBeforeNextTurn()`) helper for on-demand compaction. See [Compact in a loop](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand#compact-in-a-loop). Use it or a `context_management` compaction edit on a runner, not both.
11101110 
11111111### Debugging tool execution
11121112 
from line 1128
11281128 
11291129By default, tool errors are passed back to Claude, which can then respond appropriately. However, you might want to detect errors and handle them differently, for example, to stop execution early or implement custom error handling.
11301130 
1131In 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:
1132 
11331131<Tabs exclude="shell">
11341132 <Tab title="Python">
11351133 ```python
from line 1157
11591157 # Process the message normally
11601158 print(message.content)
11611159 ```
1160 
1161 <Note>
1162 Call
1163 
1164 `runner.generate_tool_call_response()`
1165 
1166 in the loop to get the tool results and check them for errors before the runner sends them to Claude.
1167 </Note>
11621168 </Tab>
11631169 
11641170 <Tab title="TypeScript">
from line 1198
11921198 console.log(message.content);
11931199 }
11941200 ```
1201 
1202 <Note>
1203 Call
1204 
1205 `runner.generateToolResponse()`
1206 
1207 in the loop to get the tool results and check them for errors before the runner sends them to Claude.
1208 </Note>
11951209 </Tab>
11961210 
11971211 <Tab title="C#">
from line 1312
12981312 break if message.stop_reason != :tool_use
12991313 end
13001314 ```
1315 
1316 <Note>
1317 The Ruby tool runner has no hook that returns the tool results. Once
1318 
1319 `runner.next_message`
1320 
1321 returns, they are the last entry in
1322 
1323 `runner.params[:messages]`
1324 
1325 , so check them there before the next request sends them to Claude.
1326 </Note>
13011327 </Tab>
13021328</Tabs>
13031329 
from line 1331
13051331 
13061332You can modify tool results before they're sent back to Claude. This is useful for adding metadata such as `cache_control` to enable [prompt caching](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) on tool results, or for transforming the tool output.
13071333 
1308In 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.
1309 
13101334<Tabs exclude="shell">
13111335 <Tab title="Python">
13121336 ```python
from line 1364
13401364 
13411365 print(message.content)
13421366 ```
1367 
1368 <Note>
1369 Call
1370 
1371 `runner.generate_tool_call_response()`
1372 
1373 to get the tool result, modify it, and pass it to
1374 
1375 `runner.append_messages()`
1376 
1377 so the runner does not append the original.
1378 </Note>
13431379 </Tab>
13441380 
13451381 <Tab title="TypeScript">
from line 1409
13731409 console.log(message.content);
13741410 }
13751411 ```
1412 
1413 <Note>
1414 Call
1415 
1416 `runner.generateToolResponse()`
1417 
1418 to get the tool result, then modify it in place. The runner appends the modified result for you.
1419 </Note>
13761420 </Tab>
13771421 
13781422 <Tab title="C#">
from line 1568
15241568 break if message.stop_reason != :tool_use
15251569 end
15261570 ```
1571 
1572 <Note>
1573 The Ruby tool runner has no hook that returns the tool results. Once
1574 
1575 `runner.next_message`
1576 
1577 returns, they are the last entry in
1578 
1579 `runner.params[:messages]`
1580 
1581 , so modify them there before the next request sends them to Claude.
1582 </Note>
15271583 </Tab>
15281584</Tabs>
15291585 
Feedback