Skip to content

claude-cli lifecycle/cleanup batch: silent loopback degradation, dead drain state, exit-0 failover bypass, >5MB reseed silence, image-file growth, prepare temp leaks #98946

Description

@obviyus

What happened

Batch of verified claude-cli lifecycle/cleanup defects from the reliability audit:

  1. Loopback MCP startup failure degrades silently. prepare.ts:431-438 catches ensureMcpLoopbackServer() failure and warn-continues: the generated strict mcp.json has no openclaw server, promptTools is empty, and the agent runs a full turn with no messaging/gateway tools — in message_tool_only delivery mode the visible reply is silently lost. Policy is fail loud.
  2. Dead "drain aborted turn" machinery. drainingAbortedTurn/drainTimer in claude-live-session.ts (:73-74, :385-390, :901-913, :1208-1216, :1355 pre-wave line numbers) are read in four places but never set true/non-null — dead since their introducing commit (81ca7bc). ~30 LOC of misleading state.
  3. Live process exiting 0 mid-turn bypasses failover. handleClaudeExit throws a plain Error("Claude CLI exited before completing the turn.") for exit 0, which toCliRunFailure won't convert — no model fallback, no fresh-session retry. The equivalent one-shot outcome becomes FailoverError("empty_response") and rotates the fallback chain.
  4. Transcripts >5MB silently disable reseed history. session-history.ts:23,327-337 returns [] for oversized transcripts (and swallows parse errors); since claude-cli owns native compaction, long sessions can cross 5MB and every subsequent binding invalidation reseeds with zero history, unlogged.
  5. Prompt image files are never cleaned up. writeCliImages (helpers.ts:346-368) returns a no-op cleanup by design (content-addressed path stability), but no sweeper exists anywhere — every distinct inbound image permanently adds a file to the agent workspace/tmp image root.
  6. prepare.ts leaks temp dirs on mid-prepare throws. Only prepareExecution failure (:499-506) and the context-engine block (:901-977) are guarded; throws in between (skills-plugin prep, reference-path resolution, sandbox setup, reseed loading) orphan the openclaw-cli-mcp-* / skills-plugin temp dirs.

Expected behavior

Loopback failure fails the run loudly when bundled MCP is enabled; dead drain state is deleted; clean mid-turn exits take the failover path like the one-shot equivalent; oversized transcripts reseed from a bounded tail (or at minimum log loudly); the image root gets bounded (age-based sweep); prepare cleanup is owned by one try/finally spanning all throw points.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.bugSomething isn't workingclawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.maintainerMaintainer-authored PRmaturity:stableIssue affects a taxonomy feature currently scored M4/M5.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions