Skip to content

session file locked when gateway times out and falls back to embedded runner #62981

Description

@whaili

Bug

When openclaw agent times out at the gateway and falls back to the embedded runner, the embedded runner reuses the same sessionId. The gateway process still holds the session write lock, so the embedded runner fails immediately with:

session file locked (timeout 10000ms): pid=XXXX *.jsonl.lock

This cascades to all fallback models, resulting in FallbackSummaryError: All models failed.

Root Cause

src/commands/agent-via-gateway.ts — the fallback path passes the same sessionId to agentCommand() that the gateway already has locked:

} catch (err) {
  // gateway still holds the lock on localOpts.sessionId
  return await agentCommand(localOpts, runtime, deps)  // ← same sessionId
}

Reproduction

openclaw config set agents.defaults.timeoutSeconds 60
openclaw agent --agent main --message "<long task requiring >60s to respond>"

Full error output:

Gateway agent failed; falling back to embedded: Error: gateway timeout after 90000ms
session file locked (timeout 10000ms): pid=47321 ...9e051a52.jsonl.lock
FallbackSummaryError: All models failed (3): qiniu/deepseek-v3: session file locked ... (timeout) | qiniu/kimi-k2: Request was aborted (timeout) | qiniu/glm-4.5: Request was aborted (timeout)

Confirmed on 2026.4.7-1 and 2026.4.8.

Expected Behavior

Embedded fallback should use a new sessionId (fresh session), or wait for the gateway to release the lock before attempting to acquire it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions