Skip to content

Restarting cldctrl resumes agent sessions with stale context → agent redoes finished work #15

Description

@RyanSeanPhillips

What happened

Restarting cldctrl relaunched an in-flight Claude Code session. The agent was resumed with a bare "Continue from where you left off." and a context that reflected a point ~4 commits behind actual HEAD.

The agent believed it was still mid-task on a feature it had in fact already finished, committed, and built three further slices on top of. Concretely, it thought it was still wiring a detector, when 4e0926b, e7f208f, 4365241, ae94ae1 had all landed and a PR was open.

Consequences

The agent resumed and redid completed work:

  • restarted dev servers that didn't need restarting
  • re-ran verification of already-verified, already-committed code
  • overwrote a memory file with a less-complete version (used Write, clobbering richer content written later in the same session)
  • re-derived, from scratch, a uvicorn --reload gotcha that its own memory file had already recorded — costing real time

It only self-corrected because a memory file happened to describe work beyond its context, prompting a git log check.

This run was benign only by luck: the working tree was clean and the re-derived edits happened to match what was already committed. With a dirty tree or a differing plan, the same flow could duplicate commits, re-open PRs, re-run migrations/releases, or clobber newer work. An agent told "continue" while holding stale state is being invited to repeat side effects.

Suggested fixes (roughly in order of value)

  1. Don't resume with a bare "continue" prompt. If a continuation prompt is injected on restart, prepend a state header the agent can trust: current branch, HEAD sha, git status, last N commits, open PRs.
  2. Tell the agent its context may be truncated and that it must re-orient (check git log/memory) before mutating anything. A one-line instruction would have prevented all of the above.
  3. Distinguish "resume a live session" from "relaunch after restart." The latter should reconcile state, not simply replay a continuation.
  4. Consider not auto-resuming mid-task sessions on cldctrl restart, or marking them "needs re-orientation" so the user opts in.

Notes / uncertainty

I could not find the literal string "Continue from where you left off" in this repo — resume goes through claude --resume <id> / claude --continue (cldctrl.ps1:3040, :3028). So the prompt may come from the harness, or from the dashboard/cockpit path (packages/cli/src/web/cockpit.ts has t.prompt → &prompt= on tile URLs, and 'resume:' PTY respawn). Worth confirming where the continuation text originates before fixing.

Reported from a PhysioMetrics session; filed at the operator's request.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions