[DOCS] `Build a streaming UI` miss the the check for in_tool
Resolved 💬 1 comment Opened May 20, 2026 by bobogogo1990 Closed Jun 20, 2026
Documentation Type
Missing documentation (feature not documented)
Documentation Location
https://code.claude.com/docs/en/agent-sdk/streaming-output#build-a-streaming-ui
Section/Topic
build-a-streaming-ui
Current Documentation
The docs current show:
elif event_type == "content_block_delta":
delta = event.get("delta", {})
# Only stream text when not executing a tool
if delta.get("type") == "text_delta" and not in_tool:
sys.stdout.write(delta.get("text", ""))
sys.stdout.flush()
What's Wrong or Missing?
The code miss the in_tool case process.
Suggested Improvement
elif event_type == "content_block_delta":
delta = event.get("delta", {})
delta_type = delta.get("type")
if delta_type == "text_delta" and not in_tool:
# Streaming text from Claude's response
sys.stdout.write(delta.get("text", ""))
sys.stdout.flush()
elif delta_type == "input_json_delta" and in_tool:
# ✅ Accumulate tool input JSON as it streams in
tool_input += delta.get("partial_json", "")
elif event_type == "content_block_stop":
if in_tool:
# Tool call finished — tool_input now has the complete JSON
print(f" done (input: {tool_input})", flush=True)
in_tool = False
tool_input = ""
Impact
Medium - Makes feature difficult to understand
Additional Context
_No response_
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗