fix(tasks): a requeued task starts over instead of resuming the run you cancelled - #714
Open
Adam-Dalloul wants to merge 2 commits into
Open
fix(tasks): a requeued task starts over instead of resuming the run you cancelled#714Adam-Dalloul wants to merge 2 commits into
Adam-Dalloul wants to merge 2 commits into
Conversation
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
force-pushed
the
fix/requeue-starts-a-fresh-run
branch
from
September 10, 2026 15:38
968e21e to
bf0353d
Compare
`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.
Contributor
Author
|
The CI run on the first commit (test only) is the reproduction: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_canceledmoves the row back totodoand clears the plan, the failure reason and the pending merge, but keepsconversation_id.launch_mode_forreads exactly that column to choose betweenRetryandFresh, 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 stillcancelled. The 30 second reconcile sweep reads that stale status as this generation's verdict and settles the taskcanceled, which is the 已完成 column. Nothing ever clearsconversation_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_conversationreadsSome(41)where it expectsNone.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.