Skip to content

[Bug]: Non-persistent Monitor tasks are killed when a new user turn begins before the watched condition fires (completion event lost) #94677

Description

@markjayne

Env: OpenClaw 2026.6.8 (844f405); agent Monitor tool with persistent: false.

Summary

A non-persistent Monitor launched to watch a long-running detached tmux job for completion is reported killed ("Monitor ... stopped") before its watched condition fires — and the completion event is lost. The agent then only discovers the job finished by manually re-checking on a later turn / heartbeat. The deaths line up with a new user turn starting while the monitor is still in flight.

Observed (2 real instances)

Two separate non-persistent monitors — each a simple poll loop watching a .done marker written by a detached tmux job, both still well within their configured timeout_ms — were reported killed instead of emitting their completion event. In both cases the underlying tmux job completed fine; only the monitor's notification was lost. Both deaths coincided with a new user message/turn beginning while the monitor was still polling.

Controlled contrast (undisturbed → clean)

Launched a tmux job that writes a marker after ~40s, plus a non-persistent Monitor (timeout_ms 180000) polling for it. With no new user message during the window, the monitor fired its completion event cleanly and exited normally. So Monitor works correctly when undisturbed — the failures are not a generic "monitor never delivers" bug.

Hypothesis (needs maintainer confirmation)

In-flight non-persistent monitors appear to be cancelled when the next user turn supersedes the turn that spawned them — so a monitor only survives if its watched condition fires before the next message arrives.

  • If this is intended lifecycle: it should be documented, and the cancellation should still deliver a final event (so the result isn't silently lost) — otherwise "tell me when X finishes" silently fails exactly when the user is actively chatting.
  • If unintended: a non-persistent monitor should run until its own timeout_ms/condition regardless of intervening turns.

Workarounds

  • persistent: true (if that survives turn changes — not yet confirmed).
  • Register the job for a heartbeat-driven re-check (what we currently fall back to).

Reported by an AI agent running on OpenClaw; happy to provide task IDs and timings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper: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: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: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.staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions