Skip to content

fix(server): continue threads whose background tasks outlived the turn - #49

Open
macodev00 wants to merge 1 commit into
mainfrom
cursor/continue-live-background-tasks-redo2-1f31
Open

macodev00 wants to merge 1 commit into
mainfrom
cursor/continue-live-background-tasks-redo2-1f31

Conversation

@macodev00

Copy link
Copy Markdown
Owner

What Changed

Restart continuation treats open background tasks the same as an interrupted turn.

markRunningProviderSessionsForContinuation and reconcileProviderSessions notice unterminated task.* rows (the persisted form of Claude liveTaskIds). When "Continue threads after restarts" is on, the thread is continued with a prompt that names the stopped tasks. That prompt, including the fixed text and every label, stays within PROVIDER_SEND_TURN_MAX_INPUT_CHARS. When continuation is off, or it fails, only the still-open tasks are settled once as stopped and the thread gets the existing restart notice.

An empty open-task list writes continueAfterServerUpdateTasks: null, so a stale recorded list is not reused.

A retry from a persisted starting session still restores recorded task names whenever the continuation marker is present, including after settlement already wrote task.completed rows. Promptless providers receive those names instead of { continuation: true }. listUnterminatedTasks skips activity rows whose payload is not valid JSON, and plan or dream tasks stay excluded when any decisive row has that taskType.

Why

A Claude thread whose turn has already finished can still be running subagents or background shells. The session is ready with no active turn, so a restart neither continued it nor told the user the work was lost.

This redo also closes the review findings from pingdotgg#13621: an oversized task label could make sendTurn reject the continuation, a stale task marker could settle the same tasks again, and settlement could dispatch a second completion for tasks that were already recorded.

Fixes pingdotgg#13400

UI Changes

None.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes
Open in Web Open in Cursor 

A thread can finish its turn while subagents or background shells are still running. Restart continuation only resumed sessions that were still running with an active turn, so those threads stayed ready and the work disappeared.

Startup now treats unterminated task rows like an interrupted turn. When continue-after-restart is on, the continuation prompt names the stopped tasks and stays within the provider send limit. Otherwise those tasks are settled once as stopped and the thread gets the existing restart notice.

A retry after those tasks were already settled restores the recorded names from the continuation marker, and an empty open-task list clears any stale marker. Malformed activity payloads are skipped, and plan or dream tasks stay excluded when a later status row omits taskType.

Fixes pingdotgg#13400

Co-authored-by: maco <macodev00@users.noreply.github.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L labels Sep 25, 2026

This branch has not been deployed

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

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restart continuation skips threads whose turn ended while Claude subagents or background shells were still running

1 participant