Skip to content

background lanes: API disconnect mid-run loses all work — keep worktree/branch on abnormal exit + resume from session #1132

Description

@kokevidaurre

Observed again tonight (4th occurrence this week): a squads run --background lane died 60 turns in with API Error: Connection closed mid-response (result event has is_error: true, stop_reason: stop_sequence). Nothing had been committed yet, and on exit the wrapper cleaned up the worktree — the branch is gone too, so there is nothing to salvage. All work lost.

Two gaps compound here:

  1. Abnormal exit is treated like a clean finish. The wrapper's cleanup (worktree remove) runs regardless of the result's is_error. On an error result the worktree + branch should be preserved and the log should end with a salvage pointer (path, branch, session id).

  2. No resume. The wrapper already passes a fixed --session-id to the provider CLI, so the session transcript exists after a disconnect — a bounded retry loop (--resume <session-id>, 1-2 attempts on connection-closed errors specifically) would turn a total loss into a hiccup. Transient network failure is the most common lane-death cause we see; it deserves first-class handling, not re-dispatch-from-zero.

Acceptance: kill a lane's network mid-run → wrapper retries via resume; if retries exhaust, worktree/branch survive and the final log lines say where to pick up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions