ZCode Protocol 已经把工具参数流拆成 tool_input_start / tool_input_delta / tool_input_end,这是流式 function call 的基础能力。2026-06-13 的双任务现场显示,renderer CPU 被打满并不是 agent 计算过载,而是 UI 在每个 tool_input_delta 上把累计 rawInput 重新解析成完整预览,再写入 task message store 并触发 React render。
典型 case 是一个约 36KB 的 Write 输入被拆成 785 个 delta。真实网络 delta 内容不大,但 UI 每个 delta 都扫描越来越长的累计字符串,形成近似 O(n²) 的解析和渲染成本。后台任务也同频写 store,两个任务并发时会叠加到主 renderer。
Write / Edit 输入不再每个 delta 全量解析、全量写 store。desktop-continuous 与 mobile web-remote-replayable 的交付语义边界。active 任务继续消费完整 continuous stream,但工具参数预览需要预算:
tool_input_start 立即创建工具卡。tool_input_delta 立即预览,用于快速识别 Write / Edit / Bash 等工具形态。Write / Edit 的后续 delta 只按 SessionEvent.timestamp 的 1000ms 预算预览,并把期间 suffix 合并成一次更新;累计字节增长不能绕过这个时间预算。tool_input_end 只作为轻量边界更新工具卡状态,不再解析完整 raw input;最终 tool_call 携带完整 input 时只 materialize 一次,避免 end/call 连续重复解析大 JSON。raw 只保留 streamingRawInputLength,不把完整 streamingRawInput 写进 message store。非 active 任务的后台 monitor 使用 summary profile:
tool_input_start 可创建轻量工具卡,保证后台任务看起来仍在推进。tool_input_delta 只进入 projection state 的 tombstone buffer,不写 message store、不触发 React render。rawInput、deltaCount、最近预览位置和完整 input 状态。tool_input_end 仍立即传递轻量状态;最终 tool_call、tool result、permission、elicitation、task terminal 仍然立即传递。工具状态流里同一个 tool call 的 input 可能在 tool_call_closed、scheduled、tool_queued、tool_started、tool_result_committed 等事件中重复出现。UI projection 维护 tool input materialized 状态:
tool_call 并缓存。tool_call_update,不再携带 input。inputOmitted: true 和 inputRef: "tool_call" 便于调试。ZCode Protocol 边界也需要避免重复全量:
model.streaming:tool_input_delta 在 protocol server 边界合并成较大的 diff 包;首个 delta 立即 flush,后续按既有事件时间戳预算或确定性字节预算 flush,任何非 delta 控制事件到达前也必须先 flush。Write / Edit 的 UI 可见投影在 ProductProjection / 兼容 projection 再收敛到 1000ms,不能由 protocol 字节阈值绕过。model.streaming:text_delta / reasoning_delta 也在同一协议边界合并。第一个 delta 立即 flush 保留“模型已经开始输出”的体感,后续按事件时间戳预算和确定性字节预算 flush,避免 provider 把思考流按 1-5 字符切包时唤醒 renderer 上万次,同时不能让用户感觉正文不再流式输出。streaming_tool_ledger_updated 是 runtime replay 账本,只给 agent reducer 恢复运行态使用,不再映射成 app session.updated。model.streaming:tool_call 已经交付过完整 input 后,同一 toolCallId 的 tool.updated:scheduled 不再重复携带 input。inputOmitted: true、inputRef: "model_stream" 和 inputByteLength,便于日志确认省略行为。tool_call 之前出现,或没有可证明已交付的完整 input,协议仍保留原始 input,避免破坏恢复。deliveryKind: "desktop-continuous",只是确定性 projection 对 Write / Edit 的 UI 可见输入更新降频。tool_input_delta / text_delta / reasoning_delta 的 delta 字段,不把累计 full input 放回 delta 事件;batch 边界只由首包 eager、事件时间戳预算、字节预算和事件顺序决定。时间预算必须基于 SessionEvent.timestamp 而不是 live 定时器,保证 live 与 replay 的 afterSeq 恢复边界一致。clientMode / deliveryKind。streaming-tool-input-preview.ts 不再随着每个 delta 成为主热点。Write / Edit 工具卡和首段参数;运行期间昂贵预览最多每秒 materialize 一次,收尾立即显示精确终态。+N/-N 在每个采样点原子跳到该次真实统计值,不使用逐行 requestAnimationFrame 追赶。pnpm lint 与 pnpm typecheck 通过。