# Fine Grained Tool Streaming

> Patch Claude Code cli.js to enable fine-grained tool streaming (input_json_delta). Use when tool call arguments arrive as a single burst at the end instead of streaming incrementally, when sse_lines.jsonl shows few/no input_json_delta events, or when asked to "enable tool streaming", "fix partial json", or "patch fine-grained streaming".

- Skill: `tankygranny05/fine-grained-tool-streaming` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tankygranny05/fine-grained-tool-streaming`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tankygranny05/fine-grained-tool-streaming/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: tankygranny05 (https://skillmd.com/u/tankygranny05)
- Updated: 2026-09-10
- Page: https://skillmd.com/skills/tankygranny05/fine-grained-tool-streaming

---


# Fine-Grained Tool Streaming Patch

Enables incremental streaming of tool call arguments (`input_json_delta`) in Claude Code cli.js.

## Problem

Pristine Claude Code cli.js does NOT enable the `fine-grained-tool-streaming-2025-05-14` beta by default. Tool arguments arrive as a single burst at the end instead of streaming character-by-character.

## Solution

Add `Q.push("fine-grained-tool-streaming-2025-05-14")` to the betas builder function.

## Patch Procedure

### 1. Find the patch point

```bash
grep -n "process.env.ANTHROPIC_BETAS" cli.js
```

Look for the betas builder function (typically in module `RR`, function `pp1`).

### 2. Identify the insertion point

Find these consecutive lines:
```javascript
if (G === "vertex" && ...) Q.push(...);
if (G === "foundry") Q.push(...);
if (process.env.ANTHROPIC_BETAS && !B)
```

### 3. Insert the patch

Add these 2 lines BEFORE `if (process.env.ANTHROPIC_BETAS`:
```javascript
if (G === "firstParty" && !a1(process.env.CLAUDE_CODE_DISABLE_FINE_GRAINED_TOOL_STREAMING))
  Q.push("fine-grained-tool-streaming-2025-05-14");
```

**Note:** `a1` is the env-var truthy checker (varies by version: `a1`, `B0`, etc.). Find it by searching `!a1(process.env.DISABLE_` nearby.

### 4. Run the patch script

```bash
python scripts/patch_fine_grained_streaming.py <path-to-cli.js>
```

## Verification

```bash
node cli.js --dangerously-skip-permissions --log-dir /tmp/test-fgts \
  -p "Write a 50 word story. Save to /tmp/test-fgts/story.txt"

# Check for multiple input_json_delta events
grep -c "input_json_delta" /tmp/test-fgts/sse_lines.jsonl
# Should be >10 (not 0-2)

# Check timestamps are spread out (not burst)
grep "input_json_delta" /tmp/test-fgts/sse_lines.jsonl | head -5 | jq -r '.t'
```

## Disable (if needed)

Set env var to disable:
```bash
CLAUDE_CODE_DISABLE_FINE_GRAINED_TOOL_STREAMING=1 node cli.js ...
```

