Repository navigation
fix(observe): reduceConversation copies a map only when a record writes it - #301
Merged
Merged
Conversation
…es it reduceConversation copied inputs, drops, requests and actions into new Maps on every record, though most records (assistant frames, tool calls, deltas) change none of them; inputs and requests only grow, so folding a long session was quadratic. Each map is now copied on its first write in a record, and a record that writes nothing keeps the previous maps (and their identity). The fold stays pure; the previous state is never mutated. 36,000 synthetic records (600 turns): 2.4 s -> 0.13 s locally. Ferry measured 6.7 s -> 2.1-2.4 s for its whole iOS-like (jitless) fold. Closes #300. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merged
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #300.
reduceConversationcopiedinputs,drops,requestsandactionsinto new Maps on every record, though most records (assistant frames, tool calls, deltas) change none of them.inputsandrequestsonly grow over a session, so folding a long session cost records × inputs. Ferry measuredreduceConversationas 4.7 s of 7.1 s self time for a 600-turn session in a jitless run (close to JavaScriptCore on iOS).Change: each map is wrapped in a small copy-on-write helper. It is copied on its first write in a record, and a record that writes nothing returns the previous maps unchanged, keeping their identity, so a consumer can tell the conversation didn't change. The fold stays a pure function, and the previous state is never mutated.
cursorsis still copied; it has one entry per stream.Measured locally: 36,000 synthetic records (600 turns of a prompt, its acceptance and 58 text frames),
conversationOf:Tests: a new case in
tests/conversation.test.tschecks that a text frame keeps all four maps by identity, and that a later write copies without touching the previous state. It fails without the fix. Full suite, lint and typecheck pass locally.🤖 Generated with Claude Code