-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
[Bug]: Session write-lock held beyond run lifetime when agent run fails during tool execution #100872
Copy link
Copy link
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.bugSomething isn't workingSomething isn't workingclawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper 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.Session, memory, transcript, context, or agent state can drift or corrupt.impact:ux-frictionUser-facing flow adds avoidable confusion or support burden without fully blocking progress.User-facing flow adds avoidable confusion or support burden without fully blocking progress.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.
Description
Metadata
Metadata
Assignees
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.bugSomething isn't workingSomething isn't workingclawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper 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.Session, memory, transcript, context, or agent state can drift or corrupt.impact:ux-frictionUser-facing flow adds avoidable confusion or support burden without fully blocking progress.User-facing flow adds avoidable confusion or support burden without fully blocking progress.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.
Type
Fields
Priority
None yet
Bug type
Behavior bug (incorrect output/state without crash)
Beta release blocker
No
Summary
When an agent run fails abnormally during tool execution (e.g., tool result lost triggering synthetic transcript repair), the session write-lock remains held in memory. The watchdog's force-release threshold inherits the full
maxHoldMs(up to 17 minutes for a 15-minute agent timeout), causing all subsequent requests to the same session to fail withSessionWriteLockTimeoutErroruntil the watchdog fires or the lock file is manually deleted.Steps to reproduce
timeoutSeconds >= 900(results inmaxHoldMs = 1,020,000ms)exec)session file locked (timeout 60000ms)errorExpected behavior
Lock released shortly after run terminates (within 60 seconds at most). Subsequent messages to the session should be processed normally.
Actual behavior
The session remains completely unresponsive. All new messages return:
The lock file persists on disk with
maxHoldMs: 1020000. The session can only recover by:.lockfileOpenClaw version
Latest main (commit 8f29862, 2026-07-06)
Operating system
macOS 15.3 (Apple Silicon)
Install method
ClawX desktop app (pnpm dev equivalent)
Model
anthropic/claude-sonnet-4
Provider / routing chain
openclaw -> anthropic
Additional provider/model setup details
No response
Logs
Screenshots, recordings, and evidence
Lock file contents:
{"pid":96661,"createdAt":"2026-07-06T09:32:20.160Z","maxHoldMs":1020000}The pid (96661) is the running gateway process itself. The lock was created 7 minutes before manual intervention.
Session history shows:
[openclaw] missing tool result in session history; inserted synthetic error result for transcript repairsession file lockedfailures on new messagesImpact and severity
.lockfile deletion or 17-minute waitAdditional information
Root cause analysis:
The lock remains in
SESSION_LOCKS.heldEntries()(in-memory Map) after the run terminates abnormally. BecauseheldByThisProcess = true, theorphan-self-pidstale detection is skipped. The only remaining cleanup path is the watchdog timer, which usesmaxHoldMsdirectly (derived from agent timeout + 120s grace).The existing
REPORT_ONLY_STALE_LOCK_REASONSset (too-old,hold-exceeded) prevents acquirer-side cleanup when the pid is alive, which is correct for cross-process scenarios but creates a deadlock when the same process holds a stale lock.Fix PR: #100870