Skip to content

feat(agents): show input progress for every streaming tool call - #168270

Open
TreyLawrence wants to merge 15 commits into
openclaw:mainfrom
TreyLawrence:feat/tool-input-progress-all-tools
Open

TreyLawrence wants to merge 15 commits into
openclaw:mainfrom
TreyLawrence:feat/tool-input-progress-all-tools

Conversation

@TreyLawrence

@TreyLawrence TreyLawrence commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

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_delta event for every tool call while its input streams. The event carries the tool name, the call id and inputChars, the streamed argument length so far. File-mutation tools still add their diff line counts as before. Events never include argument content. Clients that read only diff keep working, because they already skip input_delta events that have no diff.

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:

  • Every tool call reports inputChars under the same 250ms throttle and 64-call bound. Reading the length costs O(1) and nothing is parsed.
  • Only file-mutation tools parse, and only under the 1 MiB cap. Past the cap their line counts freeze while the length keeps reporting. Before this change, an oversized edit stopped reporting entirely.
  • The gateway progress snapshot keeps 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 takes partialJsonLength separately from a lazy readPartialJson. This PR applies the all-tool change inside that shared function: the length alone drives inputChars, and only file-mutation tools under the parse cap call readPartialJson. So CLI backend runs also get progress for every tool, still without assembling cumulative arguments for other tools. Main's CLI tests now expect inputChars on each event.

One limitation is unchanged by this PR. Claude 5-family models on anthropic-messages use the streaming-refusal contract, which holds all deltas until the terminal event. They therefore get no live input_delta events, for edits or any other tool.

Evidence

  • Base: 72ccf6ff92931fff2d49473fe1571f39e8311ad2 (upstream main, merged in efcb0ca662)
  • Candidate: 2bb1f3562e0

Real Gateway run (shipped entry point)

pnpm build at 465aba3 (later commits change only the in-process test), then openclaw gateway run as a separate process with token auth, in a throwaway HOME. A standalone loopback Anthropic-format provider streams a ~40KB read argument in 16 input_json_delta chunks, 500 ms apart. Observer A is a tool-events client: it sends one chat.send and logs every tool event. After three progress events, observer B connects as a fresh client while the input is still streaming and reads chat.history. argumentText is whether the event JSON contains a marker string that appears only inside the streamed argument.

$ openclaw --version: OpenClaw 2026.10.3 (465aba3)
$ openclaw gateway run --port 18789   (model mock-anthropic/claude-sonnet-4-5)
2026-10-14T03:34:50.843-04:00 [gateway] starting HTTP server...
2026-10-14T03:34:53.136-04:00 [gateway] http server listening
[observer A] + 2713ms chat.send -> status=started runId=live-1791963300798
[observer A] + 4425ms tool phase=input_delta name=read id=call_large_read inputChars=2520 diff=absent argumentText=false
[observer A] + 4905ms tool phase=input_delta name=read id=call_large_read inputChars=5040 diff=absent argumentText=false
[observer A] + 5406ms tool phase=input_delta name=read id=call_large_read inputChars=7560 diff=absent argumentText=false
[observer B] + 5500ms reconnected; observer A last saw inputChars=7560
[observer B] + 5500ms chat.history inFlightRun replay: tool phase=input_delta name=read inputChars=7560 diff=absent
[observer B] + 5500ms argument text in replayed snapshot: false
[observer A] + 5908ms tool phase=input_delta name=read id=call_large_read inputChars=10080 diff=absent argumentText=false
[observer A] + 6411ms tool phase=input_delta name=read id=call_large_read inputChars=12600 diff=absent argumentText=false
[observer A] + 6911ms tool phase=input_delta name=read id=call_large_read inputChars=15120 diff=absent argumentText=false
[observer A] + 7412ms tool phase=input_delta name=read id=call_large_read inputChars=17640 diff=absent argumentText=false
[observer A] + 7914ms tool phase=input_delta name=read id=call_large_read inputChars=20160 diff=absent argumentText=false
[observer A] + 8415ms tool phase=input_delta name=read id=call_large_read inputChars=22680 diff=absent argumentText=false
[observer A] + 8917ms tool phase=input_delta name=read id=call_large_read inputChars=25200 diff=absent argumentText=false
[observer A] + 9420ms tool phase=input_delta name=read id=call_large_read inputChars=27720 diff=absent argumentText=false
[observer A] + 9920ms tool phase=input_delta name=read id=call_large_read inputChars=30240 diff=absent argumentText=false
[observer A] +10421ms tool phase=input_delta name=read id=call_large_read inputChars=32760 diff=absent argumentText=false
[observer A] +10922ms tool phase=input_delta name=read id=call_large_read inputChars=35280 diff=absent argumentText=false
[observer A] +11422ms tool phase=input_delta name=read id=call_large_read inputChars=37800 diff=absent argumentText=false
[observer A] +11924ms tool phase=input_delta name=read id=call_large_read inputChars=40320 diff=absent argumentText=false
[observer A] +12459ms tool phase=start name=read id=call_large_read diff=absent argumentText=true
[observer A] +12483ms tool phase=result name=read id=call_large_read diff=absent argumentText=true
[observer A] +12690ms agent.wait -> ok
  • 16 counts-only input_delta events for a non-edit tool, inputChars rising from 2,520 to 40,320 over ~7.5 s, all before start.
  • The reconnecting observer's chat.history inFlightRun replays the same inputChars=7560 that observer A last saw, with no diff and no argument text.
  • Argument text appears only in start and result, which carry the arguments by design.

Live model, same build: openclaw gateway run with anthropic/claude-sonnet-4-6, asked for one exec call carrying a ~1,200-word heredoc (several thousand argument chars). Observer A received input_delta for exec at inputChars=7 and inputChars=57 before start, all with argumentText=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 no eager_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 before start, that inputChars rises strictly with no diff or argument text, and that a client reconnecting while the provider holds the stream mid-argument reads the same inputChars from chat.history. Its fixture runs client disconnect and Gateway close as runQaGatewayFixture cleanup 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.

Run Result
Proof on candidate 1/1 passed
Proof on base (main's embedded-agent-live-edit-diff.ts, proof kept) 1/1 failed: start,result: expected 0 to be greater than 0
Proof with only the snapshot's inputChars projection reverted 1/1 failed: replayed input_delta lacks inputChars
embedded-agent-live-edit-diff, cli-output-events, execute-events.tool-result-args, subscribeembeddedagentsession, server-chat-state, server-chat.agent-events 210/210 passed

pnpm tsgo, tsgo:test:root and the agents test-type project pass. oxfmt reports no issues on the changed files.

🤖 Generated with Claude Code

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]>
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: M labels Oct 10, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This 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.

  • Before: Observers receive no input progress before execution.
  • After: Observers receive counts-only inputChars updates, and a reconnecting observer recovers inputChars=7560 mid-stream.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong supplied runtime proof and a focused, correct patch resolve the previous blockers, while the broader feature contract awaits owner direction.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The supplied terminal trace exercises the changed counter and replay projection through a separately running Gateway, a real HTTP transport, chat.send, and a fresh chat.history observer; non-edit counts increase before execution and replay without argument content, and the later head changes only fixture cleanup.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Embedding clients cannot distinguish healthy long non-edit argument generation from an idle run before execution.
Reason: The capability has clear value but broadens an owner-established progress contract without recorded owner approval.

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
Reviewed head: 2bb1f3562e01ba2b16084ecf18b81ded8700b621
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should input_delta become a general streamed-argument progress contract with inputChars and optional diff?
  • Recommendation: Approve all-tool progress: Accept the shared bounded counter, counts-only payloads, and existing file-diff behavior.
  • Why: The original feature intentionally reports file-mutation progress, and neither this PR's discussion nor its linked items records approval of the broader contract.

Before merge

  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

None.

Agent review details

How this fits together

Embedded 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
Loading

Technical review

Best 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

  • Shared counter admission, payload, and oversized-input handling changes intended behavior with a stated reason (8154949: Provide bounded, monotonic, content-free live file-edit counts.)
  • Shared embedded and CLI progress ownership keeps the original intent (be3bedc: Adapt CLI fragments to the existing counter while assembling cumulative arguments lazily.)
  • Gateway progress projection changes intended behavior with a stated reason (92dc2b1: Consolidate Gateway projections without changing payloads; this PR explicitly explains retaining the new argument-length field on replay.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 8154949 adds src/agents/embedded-agent-live-edit-diff.ts:4 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 815494955d0c; files: src/agents/embedded-agent-live-edit-diff.ts)
  • Wynne668: Raw commit be3bedc adds src/agents/embedded-agent-live-edit-diff.ts:88 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: be3bedc943d0; files: src/agents/embedded-agent-live-edit-diff.ts)

PR surface

Source +25, Tests +484. Total +509 across 9 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 4 48 23 +25
Tests 5 496 12 +484
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 544 35 +509

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status no longer selects a status label.

Label justifications:

  • P2: This provides bounded observability for long tool-input generation without evidence of an urgent production regression.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-10T06:09:22.327Z sha 26b64fe :: needs real behavior proof before merge. :: [P2] Propagate fixture shutdown failures before releasing its state | [P3] Remove real-time sleeps from the Gateway regression
  • reviewed 2026-10-14T04:39:11.317Z sha 9cc15b6 :: needs real behavior proof before merge. :: [P2] Restore fixture state after body failure when shutdown succeeds
  • reviewed 2026-10-14T05:34:05.435Z sha a2e8936 :: needs real behavior proof before merge. :: [P2] Preserve fixture state when Gateway startup cleanup fails
  • reviewed 2026-10-14T06:12:19.049Z sha 465aba3 :: needs real behavior proof before merge. :: [P2] Preserve fixture state when Gateway startup cleanup fails

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.
@TreyLawrence

Copy link
Copy Markdown
Contributor Author

Merged current main and addressed both review findings in 9cc15b61313:

  • P2: the proof now runs client disconnect and Gateway close as runQaGatewayFixture cleanup phases, so shutdown failures surface. It releases env and the temporary home only after shutdown succeeds.
  • P3: the real-time chunk sleeps are gone. The Gateway proof asserts pre-start, counts-only delivery, and throttling stays covered with fake timers.

Main's #167789 split the counter, so the all-tool inputChars change now lives in the shared updateLiveEditDiffProgressFromInput. CLI backend runs get it too. The proof passes on the candidate and fails with main's counter. The PR body's Evidence section has the updated runs.

…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.
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 14, 2026
TreyLawrence and others added 2 commits October 17, 2026 14:55
…gress-all-tools

# Conflicts:
#	src/agents/cli-output-events.test.ts
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@TreyLawrence

Copy link
Copy Markdown
Contributor Author

Retriggering CI: the failing checks are outside this PR and pass on current main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@TreyLawrence

Copy link
Copy Markdown
Contributor Author

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
@TreyLawrence

Copy link
Copy Markdown
Contributor Author

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant