fix(agents): claude-cli lifecycle cleanup β loopback fail-loud, exit-0 failover, bounded reseed, image sweep, one prepare cleanup owner#99159
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 2, 2026, 12:30 PM ET / 16:30 UTC. Summary PR surface: Source +175, Tests +400. Total +575 across 9 files. Reproducibility: yes. at source level: current main still warn-continues on loopback startup failure, drops oversized transcript history, uses no-op image cleanup, and treats live exit 0 as a plain Error. I did not run a live claude-cli repro in this read-only review. Review metrics: 2 noteworthy metrics.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land only after maintainer confirmation of the fail-loud/upgrade semantics, fresh real behavior proof for the claude-cli lifecycle path, and normal PR validation; keep #98946 open until a fix merges. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main still warn-continues on loopback startup failure, drops oversized transcript history, uses no-op image cleanup, and treats live exit 0 as a plain Error. I did not run a live claude-cli repro in this read-only review. Is this the best way to solve the issue? Yes with maintainer confirmation: the patch targets the owner paths and adds focused regression coverage, but fail-loud startup and reseed/cleanup semantics are compatibility-sensitive and need real behavior proof before merge. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against dad7768da850. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +175, Tests +400. Total +575 across 9 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
Fixes #98946
What Problem This Solves
Six lifecycle/cleanup defects in the claude-cli backend from the reliability audit β the tail of the same audit that produced #98933, #98934, #98942, and #98983:
openclawserver, so agents ran whole turns with no messaging/gateway tools, and inmessage_tool_onlydelivery the visible reply was silently lost.drainingAbortedTurn/drainTimer) β never activated since their introducing commit.Error, bypassing failover entirely, while the identical one-shot outcome rotated the fallback chain viaFailoverError("empty_response").return [], parse errors swallowed) β and since claude-cli owns native compaction, long sessions can cross 5MB, after which any binding invalidation reseeded with zero context, unlogged.Why This Change Was Made
Bundled-MCP runs now fail loudly at prepare when the loopback server cannot start or publishes no runtime (no legitimate loopback-less bundleMcp mode exists β side questions and
disableToolsalready skip bundled MCP). The dead drain machinery is deleted outright. Quiet exit-0/no-result live turns classify asFailoverError("empty_response"), attaching thecli_unknown_empty_failureretry code only when the turn observed no stdout activity β mirroring the one-shot path's gates rather than inventing looser ones. Oversized transcripts reseed from a bounded 5MB tail (first partial JSONL line dropped, session header preserved) and warn once on truncation or malformed lines.writeCliImagesopportunistically sweeps files older than 7 days once per root per process (ENOENT-tolerant, debug-only on errors; the content-addressed path-stability contract is preserved β expired files are simply rewritten if needed again). Prepare cleanup now has a single try/catch owner covering every prepared resource from creation until ownership passes to the returned context, absorbing the two previous partial guards; thebeforeExecutionstaging thunk from #98983 threads through the restructure unchanged. Fixes 2 and 6 together are LOC-negative in source (+456/β458).User Impact
Loopback failures surface as actionable errors instead of silently tool-less agents and lost replies. Mid-turn clean exits now take model fallback and recovery retries. Long-running sessions keep (bounded) reseed context instead of silently losing all of it past 5MB. Image-heavy deployments stop growing disk without bound, and failed preparations stop leaking temp directories.
Evidence
git diff origin/mainis empty for that PR's landed test files (bundle-mcp.test.ts,execute.supervisor-capture.test.ts,extensions/google/setup-api.test.ts);prepare.test.tsdiffers only by this PR's own additive prepare-path tests.node scripts/run-vitest.mjsacross prepare, spawn, session-history, helpers, reliability, execute supervisor-capture, bundle-mcp, and google setup-api suites (284 tests pass); extension-boundary import gate plus the boundary/tooling Vitest pair (94 tests) β the gates that caught fix(agents): handle variadic claude --mcp-config and serialize gemini credential stagingΒ #98983's first push; full remotepnpm check:changedgreen pre-rebase on Blacksmith Testboxtbx_01kwgv54a1ak84zjy04pmesg8t(https://github.com/openclaw/openclaw/actions/runs/28572651592, exit 0); repo autoreview (branch mode vs origin/main) clean.