Skip to content

fix(tasks): a requeued task starts over instead of resuming the run you cancelled - #714

Open
Adam-Dalloul wants to merge 2 commits into
xintaofei:mainfrom
Adam-Dalloul:fix/requeue-starts-a-fresh-run
Open

fix(tasks): a requeued task starts over instead of resuming the run you cancelled#714
Adam-Dalloul wants to merge 2 commits into
xintaofei:mainfrom
Adam-Dalloul:fix/requeue-starts-a-fresh-run

Conversation

@Adam-Dalloul

Copy link
Copy Markdown
Contributor

Fixes #649: start a task, cancel it, requeue it, start it again, and it spins for a while and then lands in 已完成 as canceled. The same task never runs again; only a brand new task works.

Cause: requeue_canceled moves the row back to todo and clears the plan, the failure reason and the pending merge, but keeps conversation_id. launch_mode_for reads exactly that column to choose between Retry and Fresh, so the next start is dispatched as a resume of the run the user just cancelled: it loads the killed agent session, and it reuses the conversation row whose status is still cancelled. The 30 second reconcile sweep reads that stale status as this generation's verdict and settles the task canceled, which is the 已完成 column. Nothing ever clears conversation_id, which is why a new task is the only way out.

The change: a requeue drops the conversation link. The worktree is still reused, and the old conversation still exists in its folder; only the session pointer goes, so the next start runs the task from the top. retry (failed to queued), which deliberately continues the same session, is untouched, and the test asserts that.

The first commit is the failing test on its own, so the CI run on it shows the defect: a_requeue_drops_the_canceled_run_s_conversation reads Some(41) where it expects None.

One consequence worth calling out: while a requeued task waits in todo, the "View session" footer action is hidden, because there is no bound conversation until the next run starts. That matches what the task now is, a fresh unit of work on the board, but it is a visible change.

Start, cancel, requeue, start again lands the task in `canceled` and it
never runs again (xintaofei#649). The requeue keeps the conversation of the run the
user just stopped, and `launch_mode_for` reads exactly that column to pick
`Retry` over `Fresh`, so the second start resumes the killed session on a
conversation row still recorded as `cancelled`.

This commit is the failing half: the service test asserts the link is
dropped and currently reads `Some(41)`, and the engine test pins what the
pump does with the link either way. The fix follows.
@Adam-Dalloul
Adam-Dalloul force-pushed the fix/requeue-starts-a-fresh-run branch from 968e21e to bf0353d Compare September 10, 2026 15:38
`launch_mode_for` picks `Retry` over `Fresh` from `conversation_id` alone,
and nothing ever cleared it, so a requeued task was dispatched as a resume
of the run the user had just stopped: it loaded the killed agent session
and reused a conversation row still recorded as `cancelled`, which the
reconcile sweep then read as this generation's verdict and settled the task
`canceled`. Only a brand new task escaped.

A requeue puts the task back on the board, so it keeps the worktree and
drops the session. `retry` (failed to queued) still continues the same
session.
@Adam-Dalloul

Copy link
Copy Markdown
Contributor Author

The CI run on the first commit (test only) is the reproduction: a_requeue_drops_the_canceled_run_s_conversation failed with "a requeued task must start over, not resume the canceled session", 3574 passed / 1 failed. The second commit is the fix.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

待办任务取消流转问题

1 participant