Skip to content

Isolated cron lanes leak on claude-cli backend: queued_work_without_active_run → release_lane released=0, lanes accumulate until restart #89766

Closed

Description

@jarvis-drakon

Summary

On a long-running gateway, isolated cron jobs using the claude-cli backend intermittently get classified as stuck while they are actively streaming, and the built-in lane recovery then fails to release the lane (released=0). Leaked lanes accumulate over hours until a full gateway restart clears them. Subsequent isolated cron runs fail at the pre-runner stage with stalled before execution start (last phase: runtime-plugins).

Environment

  • OpenClaw: 2026.5.28 (e932160)
  • Runtime: claude-cli (Claude Code CLI), OAuth; models route via agentRuntime: claude-cli
  • OS: Linux, systemd user service
  • Jobs: sessionTarget: isolated, payload.kind: agentTurn

Symptoms

  1. openclaw cron list shows isolated jobs in error.
  2. Cron records: cron: isolated agent run stalled before execution start (last phase: runtime-plugins).
  3. Only isolated-target jobs are affected; main-session jobs are fine.
  4. Builds up over hours; a gateway restart flushes it (temporarily).

Diagnostic evidence (gateway journald)

[diagnostic] stuck session: sessionId=<uuid> sessionKey=agent:main:cron:<jobId>:run:<runId> state=processing age=139s queueDepth=1 reason=queued_work_without_active_run classification=stale_session_state lastProgress=cli_live:stream_progress lastProgressAge=0s recovery=checking
[diagnostic] stuck session recovery: sessionId=<uuid> ... age=139s action=release_lane aborted=false drained=true released=0
[diagnostic] stuck session recovery outcome: status=released action=release_lane ... lane=session:agent:main:cron:<jobId>:run:<runId> released=0

Key contradictions:

  • lastProgress=cli_live:stream_progress lastProgressAge=0s — the run is streaming at the instant it is classified stuck.
  • reason=queued_work_without_active_run — the lane has queued work but no active run is bound to it, despite the CLI streaming.
  • Recovery action=release_lane ... released=0 — recovery runs but frees nothing, so the lane stays occupied. This is the leak.

Ruled out

  • timeoutSeconds — the pre-runner watchdog is capped independently (per docs/automation/cron-jobs.md), so raising per-job timeouts has no effect. Confirmed.
  • Concurrency — already cron.maxConcurrentRuns: 3; lowers frequency, doesn't stop it.
  • Plugin/MCP cold-start bloat — contributes to the trigger window (CLI startup loads plugins + bundle MCP), but removing a failing plugin barely changed startup time; not the root fault.

Hypothesis

For the cli_live (claude-cli streaming) runtime there is a window where a cron run is streaming but is not (yet / any longer) registered as the lane's active run. The stuck-session classifier sees queued_work_without_active_run and calls release_lane, but because the run↔lane linkage is inconsistent, released=0 and the lane is never reclaimed. Leaked lanes eventually exhaust isolated capacity, so new isolated runs stall at the pre-runner runtime-plugins phase.

Impact

Recurring failure of scheduled isolated jobs every few hours, only mitigated by periodic gateway restarts.

Repro conditions

claude-cli backend + isolated cron jobs + gateway uptime of several hours + light concurrency. Happy to provide a debug bundle.

Activity

  1. jarvis-drakon commented on Jun 3, 2026

    @jarvis-drakon
    Author

    Related prior work — this looks like an uncovered variant of #79612

    Ask: extend the active-run/diagnostic-activity mirroring (per #81302) to cover cli_live cron isolated streaming runs, so release_lane can actually reclaim the lane instead of returning released=0. Confirmed still present on v2026.5.28.

  2. clawsweeper commented on Jun 3, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 27, 2026, 2:47 AM ET / 06:47 UTC.

    Summary
    Keep open pending a focused current-main confirmation. The merged run-lifecycle reliability work appears to address the false recovery against fresh cli_live progress, but the report’s later isolated-cron degradation and discarded-output outcome have not been verified against current main here.

    Reproducibility: unclear. for current main. The supplied candidate PR documents a deterministic source-level snapshot matching the reported fresh-progress classifier path, but no current-main live cron run was available in this review.

    Ways to help us reproduce this

    • Add a screenshot or short recording showing the behavior.
    • Add expected vs actual behavior.
    • Share version, platform, channel/provider, and relevant config details.

    Maintainer decision needed

    Question Recommendation
    Does current main still misclassify a fresh cli_live:stream_progress isolated cron turn or leave later isolated cron jobs unable to start after the merged lifecycle reliability changes? Verify current-main cron lifecycle: Run the isolated claude-cli cron scenario and close this issue if fresh progress no longer triggers recovery and later runs still admit normally.

    Why: The merged PR is strong provenance for the classifier and recovery class, but the reporter’s claimed downstream effect requires a current-main runtime observation before this issue can safely close.

    Next step
    A merged PR plausibly owns the central recovery fix, so the next action is a current-main runtime confirmation rather than another parallel repair branch.

    Review details

    Best possible solution:

    Run a bounded current-main isolated claude-cli cron scenario that observes fresh stream progress, recovery decisions, completion delivery, and subsequent cron admission; close this issue only if that confirms the merged lifecycle work resolves the reported behavior or split any remaining setup stall into a narrower canonical report.

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

    Unclear for current main. The supplied candidate PR documents a deterministic source-level snapshot matching the reported fresh-progress classifier path, but no current-main live cron run was available in this review.

    Is this the best way to solve the issue?

    Unclear. The merged lifecycle work and the narrow fresh-progress guard are plausible fixes for the observed false recovery, but a current-main run must establish whether the downstream isolated-cron admission failure is also resolved.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The merged reliability stack may eliminate the false recovery while leaving the later isolated-cron setup stall as a separate defect; closing without a current-main long-running cron check could hide that remaining behavior.
    • It is not yet proven from release provenance that the relevant merged implementation is included in the stated latest release v2026.7.1.

    Codex review notes: model internal, reasoning high; reviewed against a731397ea176.

    Label changes

    Label changes:

    • add issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.
    • add clawsweeper:needs-live-repro: Current issue advisory state selects this label.
    • remove clawsweeper:fix-shape-clear: Current issue advisory state no longer selects this label.
    • remove clawsweeper:needs-product-decision: Current issue advisory state no longer selects this label.
    • remove clawsweeper:source-repro: Current issue advisory state no longer selects this label.
    • remove impact:crash-loop: Current review impact labels are impact:session-state.
    • remove issue-rating: 🦞 diamond lobster: Current issue advisory state no longer selects this label.

    Label justifications:

    • P1: Repeated scheduled isolated-agent runs can be falsely recovered mid-stream and disrupt real user automation until operator intervention.
    • impact:session-state: The reported fault is inconsistent run, lane, and diagnostic-session lifecycle state during active work.
    Evidence reviewed

    What I checked:

    • Merged reliability candidate: The provided GitHub context identifies merged PR fix(agents): run-lifecycle reliability — bounded release, evidence-based liveness, watchdog semantics #102160 as the reliability stack covering evidence-based liveness, bounded release, and watchdog behavior; its body explicitly names this issue among the canonical reliability reports.
    • Narrow overlapping implementation candidate: Open PR fix(diagnostic): gate stuck-session fallback on fresh progress #89831 documents the exact fresh cli_live:stream_progress classification path and scopes its repair to suppress recovery while progress is within the stale threshold. (src/logging/diagnostic-session-attention.ts, 8fcf34c4f4ed)
    • Reporter evidence remains materially distinct: The July 24 report documents that recovery can stop the cron job while the Claude CLI turn continues and its side effects land without a completion result; it was observed on stable 2026.6.11, not on current main.
    • Repository policy applied: The supplied full repository AGENTS.md requires current-main, adjacent-path, and release/provenance proof before an implemented-on-main close; that proof could not be completed because read-only repository inspection was unavailable in this review environment. (AGENTS.md:1)

    Likely related people:

    • obviyus: Authored the merged run-lifecycle reliability work that explicitly lists this report and covers evidence-based liveness and recovery semantics. (role: recent area contributor; confidence: medium; files: src/logging/diagnostic-session-attention.ts, src/logging/diagnostic-session-recovery.ts, src/agents)
    • openperf: Authored the still-open narrow classifier repair for the exact fresh-progress claude-cli diagnostic state reported here. (role: adjacent fix author; confidence: medium; commits: 8fcf34c4f4ed; files: src/logging/diagnostic-session-attention.ts, src/logging/diagnostic-session-attention.test.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  3. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:crash-loopCrash, hang, restart loop, or process-level availability failure.
    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.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    on Jun 3, 2026
  4. RyanSandoval commented on Jun 10, 2026

    @RyanSandoval

    Corroborating data: still reproduces on 2026.6.5 (5181e4f) — macOS 26.5 arm64, node 26.2.0, claude-cli backend (OAuth auth-profile), LaunchAgent gateway.

    Same signature, at steady volume on a long-running gateway:

    • 26 stuck session detections on 2026-06-08, 15 on 2026-06-09, spread across ~11 different cron jobs (pollers, daily agentTurn jobs) — so it's systemic, not job-specific.
    • Every single detection fired while the run was actively streaming: lastProgress=cli_live:stream_progress with lastProgressAge of 0–14s (mostly 0s). Breakdown for 2026-06-09:
    10× reason=queued_work_without_active_run classification=stale_session_state lastProgress=cli_live:stream_progress lastProgressAge=0s
     2× … lastProgressAge=2s
     2× … lastProgressAge=4s
     2× … lastProgressAge=14s
    
    • Recovery outcome is always action=release_lane aborted=false drained=true released=0 — consistent with OP's lane-release failing to find anything to release.
    • Runs themselves usually complete status: ok despite the recovery firing mid-stream, but we also have a recent run failing with cron: isolated agent setup timed out before runner start — which looks like the downstream effect OP describes (stalled before execution start (last phase: runtime-plugins)), i.e. accumulated lane leakage degrading later isolated runs until a gateway restart.

    Also matching OP's restart observation: a gateway restart attempt was itself deferred with restart blocked by active background task run(s) while these lanes were in this state.

    Net: the queued_work_without_active_run classifier appears to not account for live cli_live:stream_progress heartbeats on the claude-cli backend — lastProgressAge=0s should presumably disqualify a session from stale_session_state.

  5. added
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    and removed
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    on Jun 15, 2026
  6. akmad commented on Jul 24, 2026

    @akmad

    Corroborating on 2026.6.11 (stable) — still present, and with a consequence worse than lane leakage: the recovery can stop the cron job while the CLI turn is alive, and the turn's side effects still land while its output is discarded.

    Setup: Linux, Docker gateway, claude-cli backend (OAuth), one-shot cron add jobs dispatching a coding agent (--session-key set, --delete-after-run).

    Two consecutive dispatches (same job shape, ~1.2KB prompt) were both classified stuck at ~2.4 min, matching the reporter's signature bit-for-bit — including lastProgress=cli_live:stream_progress lastProgressAge=0s at the moment of classification, i.e. the stream was demonstrably alive:

    [diagnostic] stuck session: sessionId=… sessionKey=agent:lovelace:cron:<jobId>:run:<runId> state=processing age=141s queueDepth=1 reason=queued_work_without_active_run classification=stale_session_state lastProgress=cli_live:stream_progress lastProgressAge=0s cronJob="…" recovery=checking
    [diagnostic] stuck session recovery: … action=release_lane aborted=false drained=true released=0 stopped="<the cron job>"
    

    What happened next in both cases: the underlying Claude CLI turn kept running (one for 12.8 min, durationMs=768781, 1703 raw stream lines), completed its work — in our case including a git push to a real PR — and was then torn down at claude live session close: reason=restart, with the turn's final output discarded. Net effect: silent zombie side-effects (the push landed) with no completion event, which is arguably more dangerous than the lane leak.

    Meanwhile a 12-minute claude-cli cron turn for a different agent on the same gateway survived untouched the same day, so the false-positive appears to be a bookkeeping race (queued item vs. active-run registration for the session), not turn length.

    Dispatching the identical payload via the gateway agent RPC (gateway call agent) instead of cron add avoids the detector entirely and ran >40 min unharmed — consistent with the cron-session bookkeeping being the trigger.

    +1 to the obvious guard: never release_lane/stop a job whose session showed stream_progress within the last few seconds — lastProgressAge=0s is right there in the diagnostic line that decides to kill it.

  7. added
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    and removed
    impact:crash-loopCrash, hang, restart loop, or process-level availability failure.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    on Jul 25, 2026
  8. steipete commented on Jul 27, 2026

    @steipete
    Contributor

    Thank you for the detailed production evidence, especially the exact cli_live:stream_progress / released=0 logs and the later Docker corroboration. I traced the actual Claude live-stream producer, diagnostic classifier, queue accounting, and recovery tests on current main; this exact false-stall and orphaned-lane behavior is now fixed.

    The canonical evidence-based liveness fix is 969efda, followed by the queued-run and recovery hardening in #114058 / 0951d0d. The liveness commit and the merged hardening PR head both have successful GitHub checks.

    Specifically:

    • The Claude live runtime emits the same cli_live:stream_progress event shown in your logs:
      ): void {
      if (parsed.type === "result") {
      emitClaudeLiveProgress(turn, "cli_live:result");
      return;
      }
      if (sawToolEvent) {
      return;
      }
      emitClaudeLiveProgress(turn, "cli_live:stream_progress");
      }
      // The CLI emits a tool_use line, then nothing until the tool result, so a
      // quiet long-running tool is indistinguishable from a wedged process at the
    • The regression test advances through 20 diagnostic heartbeat cycles while emitting that exact event, then proves no stalled event is emitted and no stuck recovery is invoked:
      it("does not classify active tool calls stalled while real progress frames arrive", () => {
      const events: DiagnosticEventPayload[] = [];
      const recoverStuckSession = vi.fn();
      const unsubscribe = onDiagnosticEvent((event) => {
      events.push(event);
      });
      try {
      startDiagnosticHeartbeat(
      {
      diagnostics: {
      enabled: true,
      },
      },
      { recoverStuckSession },
      );
      logSessionStateChange({ sessionId: "s1", sessionKey: "main", state: "processing" });
      markDiagnosticEmbeddedRunStarted({ sessionId: "s1", sessionKey: "main" });
      markDiagnosticToolStartedForTest({
      sessionId: "s1",
      sessionKey: "main",
      runId: "run-1",
      toolName: "bash",
      toolCallId: "cmd-1",
      });
      for (let i = 0; i < 20; i += 1) {
      vi.advanceTimersByTime(29_000);
      markDiagnosticRunProgressForTest({
      sessionId: "s1",
      sessionKey: "main",
      runId: "run-1",
      reason: "cli_live:stream_progress",
      });
      vi.advanceTimersByTime(1_000);
      }
      } finally {
      unsubscribe();
      }
      expect(events.some((event) => event.type === "session.stalled")).toBe(false);
      expect(recoverStuckSession).not.toHaveBeenCalled();
      });
    • The diagnostic snapshot subtracts the already-active turn from the queued backlog, preventing a live streaming turn from being mislabeled queued_work_without_active_run:
      function resolveDiagnosticQueuedBacklog(state: {
      activeQueuedTurn?: boolean;
      queueDepth: number;
      state: SessionStateValue;
      }): number {
      return Math.max(
      0,
      state.queueDepth - (state.state === "processing" && state.activeQueuedTurn ? 1 : 0),
      );
    • Real-lane integration verifies that actual stale run recovery drains queued messages rather than leaving the lane wedged:
      });
      let markActiveStarted!: () => void;
      const activeStarted = new Promise<void>((resolve) => {
      markActiveStarted = resolve;
      });
      const active = enqueueCommandInLane(
      lane,
      () =>
      new Promise<"aborted">((resolve) => {
      markActiveStarted();
      if (operation.abortSignal.aborted) {
      resolve("aborted");
      return;
      }
      operation.abortSignal.addEventListener("abort", () => resolve("aborted"), { once: true });
      }),
      { warnAfterMs: Number.MAX_SAFE_INTEGER },
      );
      const queued = enqueueCommandInLane(lane, async () => "drained", {
      warnAfterMs: Number.MAX_SAFE_INTEGER,
      });
      expect(getQueueSize(lane)).toBe(2);
      await activeStarted;
      const outcome = await recoverStuckDiagnosticSession({
      sessionId,
      sessionKey,
      ageMs: 720_000,
      queueDepth: 1,
      allowActiveAbort: true,
      });
      await expect(active).resolves.toBe("aborted");
      await expect(queued).resolves.toBe("drained");
      expect(outcome.status).toBe("aborted");
      expect(getQueueSize(lane)).toBe(0);
      });
      it("releases a wedged lane after a clean abort when session work remains queued (#91700)", async () => {
      const sessionKey = "agent:main:wedged-delivery";
      const sessionId = "wedged-delivery-session";
      const lane = resolveEmbeddedSessionLane(sessionKey);
      const operation = createReplyOperation({
      sessionKey,

    Closing as completed on main. If this signature persists on a build that includes both linked fixes, please file a new issue with the exact build and a redacted current diagnostic trace; that would be a distinct regression.

  9. locked as resolved and limited conversation to collaborators on Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper-recovery-stuckclawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.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.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions