Skip to content

feat(cli): show progress while tool input is generated - #167789

Merged
obviyus merged 2 commits into
openclaw:mainfrom
ZengWen-DT:feat/cli-tool-input-progress-167742
Oct 10, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
ZengWen-DT:feat/cli-tool-input-progress-167742

Conversation

@ZengWen-DT

@ZengWen-DT ZengWen-DT commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Closes #167742
Follow-up to #121528.

What Problem This Solves

Adds the missing CLI tool-input progress capability so chats no longer appear idle while Claude CLI generates a long Write or Edit input.

User Impact

Clients receive bounded, counts-only live edit progress before execution begins, including through the existing in-flight chat snapshot after observer reconnect. Complete tool arguments and execution-start timing are preserved; no configuration changes are required.

Why This Change Was Made

The embedded live-diff feature explicitly left CLI coverage for a follow-up. This adapts CLI input chunks to the same counter owner and existing tool / input_delta event contract, retaining its 250 ms throttle, 1 MiB parsing limit, and 64-call bound. Cumulative JSON is joined lazily after admission. Progress state is cleared at completed starts, index reuse, and stream finish.

Evidence

Candidate ca6309daeb720d45adf192d2e2798ed399be293d, tested on base 3223e13a514c6134e10ee7f585627434d245fd20, candidate tree fe9794c12b7f1e07d963631d25e10c4af6888b9e (Node 24.19.0, frozen pnpm 12.7.0).

  • Red/green: replacing only the six production files with their exact base versions makes both new fragmented Write/Edit cases fail because no progress arrives before block stop. Restoring the candidate makes all 90 tests pass across the CLI parser, shared counter, CLI event-handler, and Gateway snapshot suites (58.41 seconds wall time).
  • Real Gateway boundary: an isolated source Gateway drove the bundled CLI stdio backend with a harmless local protocol stand-in. For both Write and Edit, chat.send delivered counts-only progress while the input stream was held before block stop; a separate observer reconnected and recovered the same progress from chat.history. Before release there was no execution start; afterward there was exactly one start with complete arguments, successful agent.wait, and a final chat response. The command exited 0 in 124.573 seconds and joined its owned process tree.
  • Regression coverage includes 0/249/250 ms throttling, exact event fields, oversized-input admission, assistant-snapshot replay, index reuse, start deduplication, and existing subagent filtering. No raw file contents are added to progress events.
  • Agents-root and agents-other scoped type graphs, changed-file type-aware lint/formatting, structural guards, and all three dead-export scans passed. Canonical autoreview found no actionable P0–P2 findings.
  • The supported runtime-only build and all postbuild phases passed with explicit tsdown --concurrency 1 and the normal admission/ownership guards preserved (85.156 seconds).

Current-main composition: the patch applies cleanly to actual main 10b767dc090cf5057c2cd13b0d8d51f519f6feb5; all ten changed files remain unchanged there. The newer callable session-authority and history guards retain the progress boundary. This is source-composition verification, not a runtime rerun on that newer main.

Validation limits: the full changed-check aggregate stopped at core typechecking (exit 137); a separate core attempt and the additional Gateway-server type graph also exited 137 without TypeScript diagnostics. The exact cause was not established. Full build reached declaration publishing but failed with oneshot canceled; ordinary runtime-only parallel compilation was killed before the explicit serial runtime build passed. Locally, the full repository typecheck, full declaration/UI build, and full tests did not complete successfully. The live proof uses a local CLI stand-in, not an authenticated provider, real file mutation, or browser rendering. The PR was opened as a draft and marked ready after the exact-head review found no actionable defects and accepted the boundary proof. The normal ready-for-review CI run subsequently passed on this unchanged head: 39 jobs succeeded and 27 were intentionally skipped. Hosted production/test type checks, lint, and changed test shards passed; the build-artifacts job was intentionally skipped. CodeQL, critical-quality, OpenGrep, and the combined CI/security/dependency gate also passed. This is the repository-selected PR workflow, not a claim that every repository test ran. The local failure receipts above remain unchanged.

Maintainer verification on final head 8dc3758edbaee163e1562b62c1be18a6937c85f1, after merging main and preserving both parser finalization paths: built-Gateway comparison, real Claude Code 2.1.296 long Write (199 input-progress events before execution), 123 focused consumer tests, successful core typecheck, and runtime builds. The earlier validation limits above describe the contributor's original run; this final-head check includes authenticated native CLI execution and real file mutation.

Pash/Sarah overlap: checked a2bbcbf; its complete-preamble boundary and quiet-channel behavior are unchanged.

@clawsweeper

clawsweeper Bot commented Oct 9, 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 docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: M labels Oct 9, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The PR emits bounded line-count progress while Claude CLI generates file-mutation tool arguments.

Example: Claude CLI generates a 300-line Write.

  • Before: Clients receive no tool-input progress while the arguments stream.
  • After: The recorded final-head run delivered 199 counts-only progress events before exactly one execution start and result.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused, correct repair with shipped-entry-point proof, meaningful regression coverage, preserved lifecycle behavior, and no open findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The inspected verification comment records final-head built-Gateway comparisons and native Claude Code Write execution with counts-only progress before one start/result pair and final DONE; earlier Gateway Write/Edit proof also covers reconnect snapshots and complete arguments.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: CLI-backed chats appear idle while Claude generates large Write or Edit arguments.
Reason: Repairs the evidenced gap in an existing progress capability and completes its recorded CLI follow-up without new configuration or a competing implementation.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes a verified CLI progress gap with sufficient runtime proof and no actionable patch findings; the previously reported conflict is resolved.

Priority: P2
Reviewed head: 8dc3758edbaee163e1562b62c1be18a6937c85f1

Before merge

None.

Findings

None.

Agent review details

How this fits together

CLI JSONL output enters the shared streaming parser, which counts partial file-mutation arguments and publishes progress through the existing agent-event bus to Gateway clients and reconnect snapshots.

flowchart LR
A[Claude CLI stream] --> B[CLI JSONL parser]
B --> C[Shared bounded diff counter]
C --> D[CLI event handler]
D --> E[Agent event bus]
E --> F[Gateway clients]
E --> G[Reconnect snapshot]
Loading

Technical review

Best possible solution:

Land the focused CLI adapter while retaining the shared counter, complete-argument execution boundary, and existing recipient routing.

Do we have a high-confidence way to reproduce the issue?

Yes: current-main source drops input progress, the linked report reproduces it on official releases, and supplied Gateway comparisons record the missing pre-execution events; this review ran no target code.

Is this the best way to solve the issue?

This is a focused solution at the shared CLI parser boundary that reuses established counting and event contracts without advancing execution or exposing arguments.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against db6449d3f609.

Provenance checked

  • Shared live-diff counting keeps the original intent (8154949: Provide bounded, counts-only input progress; CLI coverage was explicitly deferred.)
  • Canonical file-mutation argument counting keeps the original intent (73ae583: Consolidate duplicated shape readers while preserving distinct streaming and completed-line semantics.)
  • Complete CLI execution arguments keeps the original intent (231348f: Preserve complete start-block input when no deltas arrive, with explicit streamed input taking precedence.)
  • Claude parent-lane filtering keeps the original intent (dfcef3a: Keep forwarded subagent tool and thinking records out of the parent conversation.)
  • Parser finalization keeps the original intent (7f47fad: Share runtime result handling without changing visible output or lifecycle ordering.)

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)

PR surface

Source +75, Tests +275, Docs +6. Total +356 across 10 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 93 18 +75
Tests 3 276 1 +275
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 375 19 +356

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +93/-18; tests +276/-1 Production growth supplies the missing CLI adapter and cleanup while reusing counting policy; tests cover fragmentation, argument preservation, throttling, resource limits, and event separation.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #167742
Summary: This PR addresses the reported CLI input-progress gap; generic all-tool progress is a separate extension.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Long CLI file mutations appear idle during input generation, but execution and final replies remain functional.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • 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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-09T11:16:30.747Z sha ca6309d :: needs maintainer review before merge. :: none
  • reviewed 2026-10-09T11:29:04.032Z sha ca6309d :: needs maintainer review before merge. :: none
  • reviewed 2026-10-09T11:49:14.369Z sha ca6309d :: needs maintainer review before merge. :: none
  • reviewed 2026-10-10T08:57:04.890Z sha ca6309d :: needs changes before merge. :: none

Reviewed October 10, 2026, 5:32 AM ET / 09:32 UTC (Revision 5).

@obviyus

obviyus commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Maintainer verification for #167742, final head 8dc3758edbaee163e1562b62c1be18a6937c85f1.

I preserved @ZengWen-DT's implementation and commits. The only follow-up is a merge of current main (cdeb1e37adc6ecfba8db436f5372c37799d2f931) to resolve the review-reported parser-finalization conflict: keep main's flushPendingClaudeText("assistant") and this PR's progress-counter cleanup in finally. No additional feature changes were needed. Thanks @umeranjum17 for the report.

Built Gateway with a deterministic CLI input stream (client advertises tool-events):

Revision First text → first execution-start event Input progress before execution Completed Write lifecycle
Baseline main 0b75e08478c567ed0e31886b6e555b720c90d81d 10.899 s 0 events; no agent activity in the gap one start, one result
Original contributor head ca6309daeb 8.367 s 29 counts-only events one start, one result
Final merged head 8dc3758edba 10.860 s 35 counts-only events one start, one result

Each run streamed 225 native input fragments. The differing wall times reflect scheduling, not a speed claim. The fix emits progress during argument generation without moving execution start earlier, leaking file contents, or duplicating starts/results. Complete-argument preservation is also covered by the parser regressions.

Real Claude Code 2.1.296, final head: a native Write created a real 300-line file and returned final DONE. First text → execution was 54.738 s; 199 counts-only input-progress events arrived before execution, starting 597 ms after the first text. Native input generation delivered 2,176 fragments over 54.799 s. Exactly one Write start and one result followed. The original contributor head also passed a native 300-line Write (100 progress events during a 28.845 s interval). The retained pre-fix native baseline had 42.121 s / 35.753 s text-to-start gaps with 0 / 1 agent events while input streamed.

Final-head checks: 123 tests passed across the CLI parser, shared live-diff counter, CLI event forwarding, Gateway snapshot, Control UI tool-stream, and Telegram progress-card suites. pnpm tsgo:core passed. Runtime builds passed in secretless Linux Docker and, after full diff review, on macOS for native CLI proof. The shared 250 ms admission throttle and resource limits are covered by boundary tests; transport arrival times can bunch slightly. Best-effort streamed line counts intentionally remain distinct from final logical line counts.

All proof Gateway/CLI processes stopped. Each native run used task-owned paths; ~/.claude/CLAUDE.md and settings.json hashes remained unchanged, and created Claude project directories were removed. No browser-rendering or live Telegram claim is made by the focused consumer tests.

Related behavior checked: a2bbcbf4068's complete-preamble phase: end boundary and quiet-channel behavior remain unchanged.

Hosted final-head outcome: ClawSweeper is ready on 8dc3758edbaee163e1562b62c1be18a6937c85f1, with no findings. CI is red only because checks-ui-e2e (1/2) fails two session-dashboard.e2e.test.ts cases: “shows a bounded visible outcome when a Canvas dashboard pin fails” and “pins an inline MCP App using only its session-bound view identity”. Both time out clicking “Pin to dashboard” because .chat-gutter-stack--details intercepts pointer events. The same two cases and obstruction fail independently on PR #167996. This CLI parser/counter diff changes neither dashboard hit testing nor the mocked UI fixture. The CI gate failure aggregates that job. Cancelled jobs in the selected CI run: 0. No jobs were rerun.

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 10, 2026
@obviyus

obviyus commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 10, 2026
@obviyus

obviyus commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

Maintainer override: the only red job is checks-ui-e2e (1/2): the two session-dashboard pin cases fail because chat-gutter-stack intercepts the Pin to dashboard click (https://github.com/openclaw/openclaw/actions/runs/38041433292/job/114182500684). The identical failure appears on unrelated PRs #59414, #167996 and #168312/#168345 (both landed with this override). Those mock-Gateway UI cases don't run the CLI parser changed here; ClawSweeper is ready on this exact head and the CLI phase reuses the existing input_delta tool phase that embedded runs already emit.

@obviyus
obviyus merged commit be3bedc into openclaw:main Oct 10, 2026
123 of 128 checks passed
@obviyus

obviyus commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

Landed in be3bedc. Thanks @ZengWen-DT for the fix and @umeranjum17 for the report: claude-cli turns now show progress while long tool inputs are written.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
claude-cli turns went silent while a tool call's input was generated, because CLI input_json_delta fragments were buffered until content_block_stop with no agent events in between (35-55 s of silence for a long Write on Claude Code 2.1.296). The CLI parser now emits the existing counts-only input_delta tool progress (shared with embedded runs) while input streams, without claiming execution started; tool start and result are unchanged. Fixes openclaw#167742.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

claude-cli route emits no agent events while a tool call's input is being generated — chat goes silent during long Write/Edit streams

2 participants