Repository navigation
fix(cli): stop session tail polling after a broken pipe - #197038
Conversation
|
🦞👀 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. |
|
Codex review: needs maintainer review before merge. What this changesStops session-tail polling when the shared CLI work scope is cancelled after output closes. Example: A consumer closes the output of
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR repairs a current CLI cleanup bug with a focused change and convincing real-pipe evidence; no actionable defects found, with exact-head CI still pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe sessions CLI reads selected sessions' SQLite trajectory events and prints progress; the shared console owner turns broken output into cancellation that the follow loop must observe. flowchart TD
A[Sessions CLI] --> B[Session selection]
B --> C[SQLite trajectory reader]
C --> D[Progress output]
D --> E[Console cancellation owner]
E --> F[Async work signal]
F --> G[Follow cleanup]
Technical reviewBest possible solution: Merge the focused cancellation repair once the required exact-head checks pass. Do we have a high-confidence way to reproduce the issue? The supplied real-CLI base receipt demonstrates the failure, and current main retains the affected polling implementation; no target code was executed during this read-only review. Is this the best way to solve the issue? This is the smallest complete repair: the follow owner observes existing command cancellation, releases its timer and listeners through existing cleanup, and preserves shared exit policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e881eb81cfec. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +10, Tests -1. Total +9 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label 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 (1 earlier review cycle)
Reviewed November 11, 2026, 1:26 AM ET / 06:26 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Proof for head 9f45e65 (main merged in; the review branch is otherwise unchanged). What changed on top of the contributor commit:
Setup: secretless Pipe case:
Controls (same on main and candidate, both runs):
Candidate source: Run logs |
|
Thanks @obviyus for tightening the follow-loop fix, simplifying the tests, and checking it with real agent turns! |
) fix(sessions): stop sessions tail --follow when its output pipe closes When the reader of openclaw sessions tail --follow closed, for example | head -n 1, the next write hit a broken pipe but the follow loop never saw the command's abort signal, so the CLI kept polling forever. The follow loop now receives the command's existing abort signal and stops once the output closes. No text changes. Evidence: the built CLI in a secretless node:24.22.1 container with a local stand-in model and real agent --local turns writing session events, two runs each. On main, after head -n 1 exited and the next turn landed, openclaw sessions tail was still running 10 s later. With this change it exits 0 within that time with nothing left running. --follow without a pipe keeps following, SIGINT exits 130, SIGTERM exits 143 and tail without --follow exits 0 on both. One abort row in the existing follow test replaces the new tests, at -1 net test lines. Details: openclaw#197038 (comment). Thanks @Alix-007. Co-authored-by: Ayaan Zaidi <[email protected]>
) fix(sessions): stop sessions tail --follow when its output pipe closes When the reader of openclaw sessions tail --follow closed, for example | head -n 1, the next write hit a broken pipe but the follow loop never saw the command's abort signal, so the CLI kept polling forever. The follow loop now receives the command's existing abort signal and stops once the output closes. No text changes. Evidence: the built CLI in a secretless node:24.22.1 container with a local stand-in model and real agent --local turns writing session events, two runs each. On main, after head -n 1 exited and the next turn landed, openclaw sessions tail was still running 10 s later. With this change it exits 0 within that time with nothing left running. --follow without a pipe keeps following, SIGINT exits 130, SIGTERM exits 143 and tail without --follow exits 0 on both. One abort row in the existing follow test replaces the new tests, at -1 net test lines. Details: openclaw#197038 (comment). Thanks @Alix-007. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit e04e7ee) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit b7941684be7db537856dcea5bb6877d84075c20d)
What Problem This Solves
Fixes:
openclaw sessions tail --followkeeps polling indefinitely after its downstream pipe closes and the next event encounters a broken pipe.User Impact
User impact: piped session followers now release their polling work when output closes. Normal following and the existing SIGINT/SIGTERM exit statuses are preserved. No configuration, storage, protocol, or migration changes.
Why This Change Was Made
The shared console owner already cancels command work on EPIPE. Session tail now observes that cancellation during selection and following, and uses its existing single cleanup path to retire the timer and listeners. Output-close exit status remains owned by the shared console policy.
Evidence
Product head:
85ad3d9763ee5b9e81f844ba2db48760788cd068; acceptance-red base:83872e599d5720c0bc97d313283a2bc245046699.openclaw.mjs sessions tail --store STORE --session-key KEY --tail 1 --followreads synthetic canonical session events. After a consumer closes the actual output pipe, a second event is committed. BASE still has live launcher and CLI processes after 6000.22 ms; HEAD naturally exits 0 in 1067.28 ms, with 0 live owned processes before cleanup and no harness signal needed.node scripts/run-vitest.mjs src/commands/sessions-tail.test.ts --maxWorkers=1: 30 passed, 75.954 seconds wall time. Targeted types, lint, format, staged test-line budget, normal CLI build, and independent adversarial review pass; review findings: None. Both existing module mock factories and their ledger are unchanged. Full-repository mock checking is left to PR CI; the overbroad local scan was cancelled, not passed.Inspectable receipts, raw streams, frozen collector, checks, and independent review. No evidence assets are committed to the product branch.
Replay and scope
Use the published
collect.pyandcollect.mtstogether on normally built, clean checkouts:EXPECTATION=redon BASE andEXPECTATION=greenon HEAD change only the expected outcome; the production entry, scenario, controls, and observation bounds are identical. Collector SHA-256:d871e72bb3c5759a2180b940043f1afed5eb6e38bc1f38e059faa9f9055ed4f2; fixture SHA-256:4e653197156364d2420f1a31c2779c9aee4faf13e335ad7805d59b5242abd128.Three files: production +22/-4, tests +40/-9 (net 31 LF) and an exact own-regression allocation. Selection cancellation, follow cancellation, raw-signal cleanup, read failures, and post-stop non-polling are covered. The canonical console cancellation owner and neighboring command observers were checked; no shared-console behavior or selector change is required.
Cleanup: only owned processes are retired; isolated fixture stores are retained in the collector output. No real sessions, providers, channels, or user data are used.
Not tested: Windows/macOS, remote Gateway selection against a live service, provider/channel traffic, and the full repository CI matrix. The native proof covers Linux / Node 26 local-store following.