Skip to content

feat(claude): stream tool call input - #302

Merged
xxchan merged 1 commit into
mainfrom
feat/tool-input-deltas
Oct 10, 2026
Merged

xxchan merged 1 commit into
mainfrom
feat/tool-input-deltas

Conversation

@xxchan

@xxchan xxchan commented Oct 10, 2026

Copy link
Copy Markdown
Member

Claude already streams tool arguments, but OAR exposed a tool only after the full input arrived. This made a host wait through a large widget argument before rendering anything.

Project native tool block openings as one tool_call_started without input, each argument fragment as append-only tool_call_input_delta { callId, delta }, and the completed block as tool_call_input. Calls without a partial opening retain their single start with complete input. Raw frames stay available.

SessionView appends raw input text within each session/agent/call, sets inputPartial: true on a fragment, and removes the flag when complete input replaces it. It never parses partial JSON, and late input cannot reopen an ended tool. The CLI waits for complete arguments before printing their detail. ACP retains whole-input updates. Codex 0.162.0 has no native argument-delta notification, verified from its generated schema.

Host impact: consumers must allow Claude's tool_call_started.input to be absent and read the later complete tool_call_input; hosts wanting early rendering can consume the deltas or the view's flagged preview. No capability flag is added.

Validation:

  • Recorded Claude 2.1.292 MCP stream: 20 KB root input, 313 fragments, full input before content_block_stop, plus an unstreamed child. Replay preserves every frame and checks live/view agreement.
  • Claude 2.1.295 with a mock provider: long escaped/Unicode MCP input on new and resumed sessions; all 40 applicable native tests passed. No real account or model quota used.
  • Unit coverage includes interleaved calls and agent lanes, empty/invalid partial JSON, complete replacement, duplicate cursors, and interrupted tools with late input.
  • Full repository check, build, and all five behavior backends passed.

Closes #299.

@xxchan
xxchan merged commit 727ade4 into main Oct 10, 2026
17 checks passed
@xxchan
xxchan deleted the feat/tool-input-deltas branch October 10, 2026 05:23
@xxchan xxchan mentioned this pull request Oct 10, 2026
xxchan added a commit that referenced this pull request Oct 10, 2026
Release OAR and CLI 0.52.0. This PR changes only the two package version
fields.

**Added: streamed tool arguments** (#299, #302)
- claude streams a tool call's arguments while the model writes them. A
streamed call now starts with `tool_call_started` without input. Each
fragment arrives as a new append-only `tool_call_input_delta { callId,
delta }`, where `delta` is claude's raw `partial_json` text and may be
incomplete JSON. The complete arguments then arrive as
`tool_call_input`, replacing the fragments.
- `SessionView`: a tool part's `input` grows with the fragments and
carries `inputPartial: true` until the complete input arrives. An
interrupted call keeps `inputPartial`. OAR never parses partial JSON; a
host that renders early uses a tolerant parser and acts only once
`inputPartial` clears.
- Only claude streams arguments. Its subagents' tool calls, codex and
the ACP runtimes still give the whole input at once.

**Fixed**
- **`reduceConversation` no longer copies its maps on every record**
(#300, #301). A map is copied only on its first write in a record, and a
record that changes nothing keeps the previous maps, and their identity.
A 600-turn session (35,400 records) folds about 4.5× faster: 2.4 s →
0.52 s with JIT, 2.7 s → 0.60 s without.

**Behavior changes**
- A claude `tool_call_started` may now carry no `input`; read the later
`tool_call_input` (or the view) before parsing arguments. Hosts that
already handle ACP runtimes, whose input also arrives later, are
unaffected.
- `classifyTool` should be given only complete input; `tool-groups`
already skips partial input.
- Hosts with an exhaustive `switch` over event kinds need a case for
`tool_call_input_delta`.

Validation: #301 and #302 each passed all 17 checks on their final heads
(`5885611`, `a712e02`). #301 merged with a tree equal to its CI tree.
#302 was checked on the previous main; it and #301 touch different
files, so the combination was verified locally (typecheck, lint, full
tests: 1507 passed), and the merged tree equals that verified tree.
Lookout verified #301 with a differential fold of 61,429 steps (0
differences) and #302 on four cases against the real claude CLI with a
mock provider (two tools streaming in one message, an interrupt
mid-argument, a resume, a subagent). After this PR passes CI and merges,
tag its exact squash commit as `v0.52.0` to trigger npm trusted
publishing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
xxchan added a commit that referenced this pull request Oct 10, 2026
…uments; phaseLabel names the action (#317)

Closes #314.

Since 0.52 (#302), a claude call's `tool_call_started` arrives at
`content_block_start`, before its arguments stream. `AgentStatus.phase`
became `{ tool }` right there, so `phaseLabel` read `Running
mcp__ferry__show_widget` for the whole time the model was writing the
arguments. Ferry measured 9–14 s for a 2.5–4.5 KB widget.

**Changes:**
- **`RunningPhase` tool variant gains `writing?: true`.** It is set from
the call's first `tool_call_input_delta` until its complete
`tool_call_input`, and only for the current call's phase. Only deltas
set it: an ACP call whose input arrives later without deltas is already
running. In practice only claude streams arguments.
- **`phaseLabel(phase, runtimeId?)`:**
  - a writing phase reads `Writing <tool> arguments`;
- with a runtime id, a running call reads as its action from
`classifyTool` / `toolActionLabel` (`Editing file`, `Running command`),
and an MCP or unclassified tool by its short name (`Running
show_widget`);
  - without a runtime id, today's wording stays.
- **Docs:** docs/spec/conversation.md.

**Tests:**
- Status: writing during deltas, cleared by the complete input,
untouched by another call's input. It fails without the change.
- Labels: actions, MCP short name, unclassified, and writing with and
without a runtime id.

The full suite (1,582), lint and typecheck pass locally.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

claude: report a tool call's input as it streams (input_json_delta), so hosts can render long arguments early

2 participants