The whole hunk
from line 130, old and new numbered
/
lines
from line 130
130130 tool_results: list[BetaToolResultBlockParam] = []
131131 for block in response.content:
132132 if block.type == "tool_use":
133 path = str(block.input["path"])
133 raw_path = block.input.get("path")
134 path = raw_path if isinstance(raw_path, str) else ""
134135 if path in FILES:
135136 tool_results.append(
136137 {
from line 256
255256 }
256257
257258 const finalText = response.content.find((block) => block.type === "text");
258 console.log(finalText?.text);
259 console.log(finalText?.text ?? "");
259260 ```
260261
261262 ```csharp C#
from line 334
333334 {
334335 if (block.TryPickToolUse(out var toolUse))
335336 {
336 var path = toolUse.Input["path"].GetString()!;
337 var path = toolUse.Input.TryGetValue("path", out var pathValue)
338 && pathValue.ValueKind == JsonValueKind.String
339 ? pathValue.GetString()!
340 : "";
337341 if (files.TryGetValue(path, out var fileText))
338342 {
339343 toolResults.Add(new BetaToolResultBlockParam { ToolUseID = toolUse.ID, Content = fileText });
from line 450
446450 var input struct {
447451 Path string `json:"path"`
448452 }
453 // A missing or non-string path leaves input.Path empty, which takes the error-result branch.
449454 if err := json.Unmarshal([]byte(toolUse.JSON.Input.Raw()), &input); err != nil {
450 log.Fatal(err)
455 input.Path = ""
451456 }
452457 text, found := files[input.Path]
453458 if !found {
from line 553
548553 for (BetaToolUseBlock toolUse : toolUses) {
549554 Map<String, JsonValue> input =
550555 (Map<String, JsonValue>) toolUse._input().asObject().orElseThrow();
551 String path = input.get("path").asStringOrThrow();
556 String path = Optional.ofNullable(input.get("path"))
557 .flatMap(JsonValue::asString)
558 .orElse("");
552559 String fileText = FILES.get(path);
553560 BetaToolResultBlockParam.Builder result = BetaToolResultBlockParam.builder()
554561 .toolUseId(toolUse.id());
from line 582
575582
576583 String finalText = response.content().stream()
577584 .flatMap(block -> block.text().stream())
585 .map(textBlock -> textBlock.text())
578586 .findFirst()
579 .orElseThrow()
580 .text();
587 .orElse("");
581588 IO.println(finalText);
582589 }
583590 ```
from line 644
637644 $toolResults = [];
638645 foreach ($response->content as $block) {
639646 if ($block->type === 'tool_use') {
640 $path = $block->input['path'];
647 $path = is_string($block->input['path'] ?? null) ? $block->input['path'] : '';
641648 if (array_key_exists($path, FILES)) {
642649 $toolResults[] = [
643650 'type' => 'tool_result',
from line 673
666673 }
667674
668675 $textBlock = array_find($response->content, fn ($block) => $block->type === 'text');
669 echo $textBlock->text, PHP_EOL;
676 echo $textBlock?->text ?? '', PHP_EOL;
670677 ```
671678
672679 ```ruby Ruby
from line 877
870877* Append the following note to the end of the user message. It makes the thinking much shorter on prose and code requests. Replace `[max_tokens]` with the request's actual `max_tokens` value, for example 64,000.
871878
872879```text wrap
873Everything produced in one reply, including any reasoning or drafting it does before the reply, counts toward a single limit of about [max_tokens] tokens. If that limit is reached before the reply is finished, the person receives a cut-off response and has to start over. Composing an entire output or deliverable in full as reasoning and then again as a reply would double the length of the turn without improving the result, so don't do that.
880Everything produced in one reply, including any reasoning or drafting done before the reply, counts toward a single limit of about [max_tokens] tokens. If that limit is reached before the reply is finished, the person receives a cut-off response and has to start over. Composing an entire output or deliverable in full as reasoning and then again as a reply would double the length of the turn without improving the result, so don't do that.
874881
875882Instead, when the person has asked for a long or effort-intensive deliverable such as a multi-section document, a large table or dataset, or a complete code file, spend extra effort on understanding the request, checking the inputs the answer depends on, settling the structure and other difficult decisions, and otherwise using the reasoning space to reason and the output space to write an output. Usually it is not needed to draft an output multiple times.
876883```