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

fine-grained-tool-streaming changedagents-and-tools/tool-use/fine-grained-tool-streaming

Nearest release: v2.1.309, published 3 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+18added
Lines−18removed
From line 474 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits13to this page, all time

The whole hunk

from line 474, old and new numbered
/
lines
from line 474
474474Complete tool input: {"filename": "poem.txt", "lines_of_text": ["The Wanderer's Journey", ...]}
475475```
476476 
477Without `eager_input_streaming`, the API buffers and validates each parameter value before streaming it back, so nothing prints for a large parameter until Claude has finished generating it. With it, fragments start arriving as soon as Claude begins the parameter, and they are typically longer, with fewer mid-word breaks.
477Without `eager_input_streaming`, the API buffers and validates each parameter value before streaming it back, so nothing prints for a large parameter until Claude has finished generating it. With it, fragments arrive from the moment Claude starts the parameter, and they are typically longer, with fewer mid-word breaks.
478478 
479479## Accumulating tool input deltas
480480 
from line 490
4904902. For each `content_block_delta` with `type: "input_json_delta"`, append: `input_json += event.delta.partial_json`.
4914913. On `content_block_stop`, parse the accumulated string.
492492 
493Guard the parse, as the following example does. A response can also stop at `max_tokens` midway through a parameter. Check the [stop reason](https://platform.claude.com/docs/en/build-with-claude/handling-stop-reasons) and decide whether to retry the request with a higher `max_tokens` or repair the partial input.
493Guard the parse, as the following SDK example does. A response can also stop at `max_tokens` midway through a parameter. Check the [stop reason](https://platform.claude.com/docs/en/build-with-claude/handling-stop-reasons) and decide whether to retry the request with a higher `max_tokens` or repair the partial input.
494494 
495495The type mismatch between the initial `input: {}` (object) and `partial_json` (string) is by design. The empty object marks the slot in the content array. The delta strings build the real value.
496496 
from line 724
724724 ObjectMapper objectMapper = new ObjectMapper();
725725 
726726 Tool weatherTool = Tool.builder()
727 .name("get_weather")
728 .description("Get current weather for a city")
729 .eagerInputStreaming(true)
730 .inputSchema(Tool.InputSchema.builder()
731 .properties(Tool.InputSchema.Properties.builder()
732 .putAdditionalProperty("city", JsonValue.from(Map.of("type", "string")))
733 .build())
734 .addRequired("city")
735 .build())
736 .build();
727 .name("get_weather")
728 .description("Get current weather for a city")
729 .eagerInputStreaming(true)
730 .inputSchema(Tool.InputSchema.builder()
731 .properties(Tool.InputSchema.Properties.builder()
732 .putAdditionalProperty("city", JsonValue.from(Map.of("type", "string")))
733 .build())
734 .addRequired("city")
735 .build())
736 .build();
737737 
738738 MessageCreateParams createParams = MessageCreateParams.builder()
739 .model(Model.CLAUDE_OPUS_5_5)
740 .maxTokens(1024)
741 .addTool(weatherTool)
742 .addUserMessage("Weather in Paris?")
743 .build();
739 .model(Model.CLAUDE_OPUS_5_5)
740 .maxTokens(1024)
741 .addTool(weatherTool)
742 .addUserMessage("Weather in Paris?")
743 .build();
744744 
745745 // Content block index -> accumulated tool input JSON
746746 Map<Long, StringBuilder> toolInputs = new HashMap<>();
from line 830
830830 $accumulated = $toolInputs[$event->index];
831831 try {
832832 $parsed = json_decode($accumulated, associative: true, flags: JSON_THROW_ON_ERROR);
833 echo "Tool input: " . json_encode($parsed) . "\n";
833 echo 'Tool input: ' . json_encode($parsed) . "\n";
834834 } catch (\JsonException $e) {
835835 // The accumulated string is not guaranteed to be valid JSON.
836836 // See "Handling invalid JSON in tool responses" on this page.
Feedback