Skip to content

shellper/launch loops: auto-restart should only trigger on unnatural exits — a deliberate quit should end cleanly #1241

Description

@waleedkadous

Problem

When the user deliberately exits the agent in a terminal — double Ctrl+C, /quit, or any clean exit — the restart machinery treats it like a crash: the launch-script loop prints Agent exited. Restarting in 2 seconds... and respawns, and the shellper's auto-restart does the same at its layer. The user made a choice; overriding it forces them to race another Ctrl+C into the 2-second window (and a mistimed one lands in the fresh agent instead). It also feeds the #1224 class: a killed claude respawned within ~2s can collide with its own dying predecessor's session lock.

Design (prescribed — keep BUGFIX-sized)

Exit code 0 = natural exit = the user's choice. Never restart on it.

Two surfaces enforce restart today; both should adopt the same rule:

  1. Builder launch scripts (the while true loops in spawn-worktree.ts-generated .builder-start.sh, incl. the Kimi provider-owned variants): on child exit 0, break the loop, clear the screen, print a one-liner ("Agent exited at your request. Press Enter to relaunch, or close this terminal.") — a keypress-gated relaunch keeps recovery one keystroke away without auto-respawning.
  2. Shellper auto-restart (session-manager.tssetupAutoRestart): exit code 0 → do not count it as a failure and do not respawn; leave the PTY open with the clean-exit message.

Nonzero exits and signal deaths keep today's restart behavior (that's what auto-recovery is for). No config knob needed.

Acceptance

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/towerArea: Tower server / agent farm CLI

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions