Repository navigation
feat(agents): show input progress for every streaming tool call - #168270
TreyLawrence wants to merge 15 commits into
Conversation
The embedded runner forwarded counts-only `tool` / `input_delta` progress only for write, edit and apply_patch. Any other tool with a long argument streamed for minutes with no progress event, so clients with idle or turn deadlines could not tell a slow generation from a stalled one. Every tool call now reports `inputChars`, the streamed argument length, under the existing 250ms throttle and 64-call bound. File-mutation tools still add their line counts; parsing stays limited to them and to the 1 MiB cap, past which the counts freeze while the length keeps reporting. Events never carry argument content. Gateway replay snapshots keep `inputChars`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Codex review: blocked before merge. What this changesThis PR reports argument-length progress for all streaming tool calls and preserves it in Gateway reconnect snapshots. Example: A read call streams a 40,320-character JSON argument.
Review scores
ProductKind: Feature · Worth it: Needs a maintainer decision · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open: current main lacks this useful capability, no actionable code findings remain, and approval of the broader progress contract is still needed. Priority: P2 Decision needed
Before merge
FindingsNone. Agent review detailsHow this fits togetherEmbedded model events and CLI argument fragments enter the shared bounded counter, which publishes progress through agent events and Gateway replay snapshots. flowchart LR
A[Embedded model stream] --> C[Shared progress counter]
B[CLI argument fragments] --> C
C --> D[Agent event bus]
D --> E[Gateway subscribers]
D --> F[Reconnect snapshot]
F --> E
Technical reviewBest possible solution: Approve and retain the existing shared counter as the owner of content-free all-tool progress. Do we have a high-confidence way to reproduce the issue? Current-main source rejects non-file-mutation tools, matching the reported base-failing Gateway regression; no target code was executed during this review. Is this the best way to solve the issue? Extending the shared counter is a focused solution that preserves lifecycle ownership, parsing limits, and content-free progress, subject to approval of the expanded contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against addf1939d321. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +25, Tests +484. Total +509 across 9 files. Added test files: 1. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (4 earlier review cycles)
Reviewed October 14, 2026, 3:45 AM ET / 07:45 UTC (Revision 5). |
…gress-all-tools # Conflicts: # src/agents/embedded-agent-live-edit-diff.ts
- The real-runtime proof now runs client disconnect and Gateway close as runQaGatewayFixture cleanup phases, so their failures surface, and it restores env and removes the temporary home only after shutdown succeeds. - The proof no longer sleeps between provider chunks. It asserts that counts-only progress arrives before the tool starts. Throttle windows stay covered with fake timers in the counter's unit test. - Main's new CLI and shared-counter tests now expect inputChars on every progress event and keep a call tracked past the parse cap.
|
Merged current main and addressed both review findings in
Main's #167789 split the counter, so the all-tool |
…ss fixture - The proof records shutdown phase failures and, in a finally, restores env and removes its temporary home whenever every shutdown phase succeeded, including when the test body failed. State is still retained only when shutdown failed. - The execute-events input-progress fixture now carries inputChars, which CliToolInputDelta requires.
The loopback provider now holds the tool argument at its midpoint until the test releases it. While the input is still streaming, a second client reads chat.history, and the proof asserts that the in-flight snapshot replays the same inputChars the live observer last saw, with no diff and no argument content. Reverting the snapshot's inputChars field fails this assertion.
A rejected startGatewayWithClient may leave its own cleanup unverified, so the proof now marks shutdown as failed and keeps env and the temporary home.
…gress-all-tools # Conflicts: # src/agents/cli-output-events.test.ts
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Retriggering CI: the failing checks are outside this PR and pass on current main. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Retriggering CI: the failing e2e tests are outside this PR and pass on current main. |
…gress-all-tools # Conflicts: # src/agents/embedded-agent-live-edit-diff.test.ts
…gress-all-tools # Conflicts: # src/gateway/server-chat-state.test.ts
|
Retriggering CI: the failing checks are outside this PR and pass on current main. |
…gress-all-tools # Conflicts: # src/agents/cli-runner/execute-events.tool-result-args.test.ts
What Problem This Solves
When a model streams a long argument for any tool other than write, edit or apply_patch, no progress is reported while the input is generated, which can take minutes. An embedding client that watches the run sees nothing until the tool starts. If it enforces idle or turn deadlines, it ends up killing generations that are slow but healthy.
User Impact
Clients now receive the existing counts-only
tool/input_deltaevent for every tool call while its input streams. The event carries the tool name, the call id andinputChars, the streamed argument length so far. File-mutation tools still add theirdiffline counts as before. Events never include argument content. Clients that read onlydiffkeep working, because they already skipinput_deltaevents that have nodiff.Why This Change Was Made
#121528 added a bounded, throttled counter for live edit progress. This PR widens it instead of adding a second path:
inputCharsunder the same 250ms throttle and 64-call bound. Reading the length costs O(1) and nothing is parsed.inputChars, so reconnect replay shows the same event.Relation to #167789 (CLI backend progress for Write/Edit, now on main): main split the counter into
updateLiveEditDiffProgressFromInput, which takespartialJsonLengthseparately from a lazyreadPartialJson. This PR applies the all-tool change inside that shared function: the length alone drivesinputChars, and only file-mutation tools under the parse cap callreadPartialJson. So CLI backend runs also get progress for every tool, still without assembling cumulative arguments for other tools. Main's CLI tests now expectinputCharson each event.One limitation is unchanged by this PR. Claude 5-family models on
anthropic-messagesuse the streaming-refusal contract, which holds all deltas until the terminal event. They therefore get no liveinput_deltaevents, for edits or any other tool.Evidence
72ccf6ff92931fff2d49473fe1571f39e8311ad2(upstream main, merged inefcb0ca662)2bb1f3562e0Real Gateway run (shipped entry point)
pnpm buildat465aba3(later commits change only the in-process test), thenopenclaw gateway runas a separate process with token auth, in a throwawayHOME. A standalone loopback Anthropic-format provider streams a ~40KBreadargument in 16input_json_deltachunks, 500 ms apart. Observer A is atool-eventsclient: it sends onechat.sendand logs everytoolevent. After three progress events, observer B connects as a fresh client while the input is still streaming and readschat.history.argumentTextis whether the event JSON contains a marker string that appears only inside the streamed argument.input_deltaevents for a non-edit tool,inputCharsrising from 2,520 to 40,320 over ~7.5 s, all beforestart.chat.historyinFlightRunreplays the sameinputChars=7560that observer A last saw, with nodiffand no argument text.startandresult, which carry the arguments by design.Live model, same build:
openclaw gateway runwithanthropic/claude-sonnet-4-6, asked for oneexeccall carrying a ~1,200-word heredoc (several thousand argument chars). Observer A receivedinput_deltaforexecatinputChars=7andinputChars=57beforestart, all withargumentText=false. The marker was a word that appears only in the essay. The model spent ~43 s generating the call, but the long string value arrived in one burst at the end. The run used OpenClaw's managed Anthropic transport, which sends noeager_input_streaming(packages/ai/src/transports/anthropic-messages.ts), so Anthropic buffers long string parameters. The counter reports exactly what the provider delivers. Unbuffered transports, such as the loopback run above or providers with eager input streaming, give continuous progress. The live run finished before observer B's reconnect, so it shows no replay.Tests
The in-process proof
test/pr168270-real-runtime-proof.e2e.test.ts(startGatewayWithClient, same loopback provider shape, no real-time sleeps) asserts that progress arrives beforestart, thatinputCharsrises strictly with nodiffor argument text, and that a client reconnecting while the provider holds the stream mid-argument reads the sameinputCharsfromchat.history. Its fixture runs client disconnect and Gateway close asrunQaGatewayFixturecleanup phases. It releases env and the temporary home only when startup and every shutdown phase succeeded, and it does release them when only the body failed.embedded-agent-live-edit-diff.ts, proof kept)start,result: expected 0 to be greater than 0inputCharsprojection revertedinput_deltalacksinputCharsembedded-agent-live-edit-diff,cli-output-events,execute-events.tool-result-args,subscribeembeddedagentsession,server-chat-state,server-chat.agent-eventspnpm tsgo,tsgo:test:rootand the agents test-type project pass. oxfmt reports no issues on the changed files.🤖 Generated with Claude Code