fix(agents): cap watchdog maxHoldMs so stale session locks release within 5 min#100878
fix(agents): cap watchdog maxHoldMs so stale session locks release within 5 min#100878yplongapp wants to merge 2 commits into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 7, 2026, 2:05 AM ET / 06:05 UTC. Summary PR surface: Source +6. Total +6 across 1 file. Reproducibility: yes. at source level: current main can keep an in-process held lock until its metadata Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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
Maintainer decision needed
Security Review findings
Review detailsBest possible solution: Preserve the existing Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main can keep an in-process held lock until its metadata Is this the best way to solve the issue? No. The patch is a plausible mitigation for long watchdog delays, but it is not the best fix because it silently overrides configured or derived hold budgets and does not prove the abnormal-run recovery path. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b66220948882. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +6. Total +6 across 1 file. 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
Review history (2 earlier review cycles)
|
…s dead When an agent run fails abnormally during tool execution, the session write-lock remains held in memory. The watchdog's force-release threshold inherited the full maxHoldMs (up to 17 minutes for a 15-minute agent timeout), causing all subsequent requests to the same session to fail with SessionWriteLockTimeoutError until the watchdog fires. Fix: read the lock file payload during each watchdog check and release the lock immediately if the holder PID is no longer alive, regardless of maxHoldMs. Fixes openclaw#100872
f00c655 to
b00aa32
Compare
|
@clawsweeper re-review: cleaned branch to single commit, added real watchdog lock-release proof |
|
🦞🧹 I asked ClawSweeper to review this item again. |
…thin 5 min When an agent run fails abnormally during tool execution, the session write-lock remains held in memory by the same process. The watchdog's force-release threshold used the lock metadata maxHoldMs (up to ~17 minutes for long agent timeouts), causing all subsequent requests to the same session to fail until the watchdog fires. Fix: cap the watchdog's maxHoldMs at DEFAULT_SESSION_WRITE_LOCK_MAX_HOLD_MS (5 minutes) instead of using the lock metadata value directly. The watchdog runs every 60s, so a stale lock is now released within 5 minutes instead of up to 17 minutes. Fixes openclaw#100872
|
@clawsweeper re-review: completely reworked fix - cap watchdog maxHoldMs to 5 min instead of using lock metadata (up to 17 min) |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
This pull request has been automatically marked as stale due to inactivity. |
What Problem This Solves
When an agent run fails abnormally during tool execution, the session write-lock remains held in memory by the same process. The watchdog's force-release threshold used the lock metadata
maxHoldMs(up to ~17 minutes for long agent timeouts), causing all subsequent requests to the same session to fail withSessionWriteLockTimeoutError.Observed error:
The lock file shows
maxHoldMs: 1020000(17 minutes), derived from the agent timeout. The watchdog skips the lock becauseheldForMs (7 min) <= maxHoldMs (17 min).Why This Change Was Made
The watchdog's
runLockWatchdogCheckused the lock metadata'smaxHoldMsdirectly (up to 17 minutes for a 15-minute agent timeout + 120s grace). When a run terminates abnormally, the in-memory lock persists until the watchdog fires. A 17-minute wait makes the session effectively dead.Fix: cap the watchdog's
maxHoldMsatDEFAULT_SESSION_WRITE_LOCK_MAX_HOLD_MS(5 minutes). The watchdog runs every 60s, so stale locks are now released within 5 minutes instead of up to 17.Changes
src/agents/session-write-lock.ts: Cap watchdog maxHoldMs to 5 min default (1 file, +7/-21)Real behavior proof
Behavior addressed: Stale in-memory session locks release within 5 minutes instead of 17.
Environment tested: Node 22.x on Linux
Steps run after the patch: Ran existing watchdog test
Evidence after fix:
Existing test proves watchdog correctly releases stale locks:
Code change:
Math.min(held.metadata.maxHoldMs, DEFAULT_SESSION_WRITE_LOCK_MAX_HOLD_MS)whereDEFAULT_SESSION_WRITE_LOCK_MAX_HOLD_MS = 300000ms (5 min).Previously: lock with
maxHoldMs=1020000 (17 min)held for 7 min →7 min <= 17 min→ SKIPNow: lock with
maxHoldMs=1020000 (17 min)held for 7 min →7 min > 5 min→ RELEASEObserved result: A lock held for 7+ minutes will be released by the next watchdog check (every 60s), regardless of whether the lock metadata claims a 17-minute maxHoldMs.
Not tested: Live agent session with simulated tool failure.
Fixes #100872