handling-stop-reasons changedbuild-with-claude/handling-stop-reasons
Nearest release: v2.1.304, published 6 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+5added
Lines−15removed
From line
97
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits19to this page, all time
The whole hunk
from line 97, old and new numbered
/
from line 97
9797
9898 if (response.stop_reason === "end_turn") {
9999 // Process the complete response
100 const textBlock = response.content.find(
101 (block): block is Anthropic.TextBlock => block.type === "text"
102 );
100 const textBlock = response.content.find((block) => block.type === "text");
103101 console.log(textBlock?.text);
104102 }
105103 ```
from line 2101
21032101 return handleRefusal(response);
21042102 default: {
21052103 // Handle end_turn and other cases
2106 const textBlock = response.content.find(
2107 (block): block is Anthropic.Beta.BetaTextBlock => block.type === "text"
2108 );
2104 const textBlock = response.content.find((block) => block.type === "text");
21092105 return textBlock?.text ?? "";
21102106 }
21112107 }
from line 2222
22262222
22272223 ```typescript TypeScript
22282224 function handleTruncatedResponse(response: Anthropic.Beta.BetaMessage): string {
2229 const textBlock = response.content.find(
2230 (block): block is Anthropic.Beta.BetaTextBlock => block.type === "text"
2231 );
2225 const textBlock = response.content.find((block) => block.type === "text");
22322226 const text = textBlock?.text ?? "";
22332227
22342228 if (
from line 3238
32443238 messages
32453239 });
32463240
3247 const textBlock = response.content.find(
3248 (block): block is Anthropic.TextBlock => block.type === "text"
3249 );
3241 const textBlock = response.content.find((block) => block.type === "text");
32503242 fullResponse += textBlock?.text ?? "";
32513243
32523244 if (response.stop_reason !== "max_tokens") {
from line 3494
35023494 console.log(`Generated ${tokens} tokens (natural completion)`);
35033495 }
35043496
3505 const textBlock = response.content.find(
3506 (block): block is Anthropic.Beta.BetaTextBlock => block.type === "text"
3507 );
3497 const textBlock = response.content.find((block) => block.type === "text");
35083498 return textBlock?.text ?? "";
35093499 }
35103500 ```
No line in this hunk matches that.