Skip to content

fix(suite): stop suites stalling and agents spinning - #241

Open
Centaurus99 wants to merge 7 commits into
suite-agentfrom
suite-task-reclaim
Open

fix(suite): stop suites stalling and agents spinning#241
Centaurus99 wants to merge 7 commits into
suite-agentfrom
suite-task-reclaim

Conversation

@Centaurus99

@Centaurus99 Centaurus99 commented Aug 15, 2026

Copy link
Copy Markdown
Member

Three ways a suite could stall, or keep agents busy doing nothing:

  • incomplete_tasks lost its decrements. Submission wrote back prev + 1 read from an unlocked row, overwriting any incomplete_tasks - 1 a commit landed in between. A 4974-task suite settled at 4476 with every task finished, so -W never returned. Both counters now move by column expression, and the decrement moves inside the archiving transaction on both commit paths.

  • Uncommitted tasks were stranded. An agent completing its job while holding Running/Finished/Cancelled tasks left them in active_tasks forever, unclaimable by anyone. agent_complete_job now reclaims them back to Ready for a re-run, dropping that run's results.

  • Agents spun on a suite with nothing to claim. suite_has_work asked for incomplete_tasks > 0, which also counts tasks running elsewhere; one suite accumulated 25k accept/complete jobs. It now requires a Ready task, and an agent whose job ran no task no longer re-accepts immediately.

🤖 Generated with Claude Code

@BobAnkh
BobAnkh requested a review from un-lock-able August 15, 2026 17:20
Decrement inside the archiving transaction, increment by column
expression, and fold the cancelled-suite check into that statement.
Offer a suite only while it holds a Ready task, and skip the immediate
re-accept after a job that ran none.
@Centaurus99 Centaurus99 changed the title fix(suite): stop uncommitted tasks from stalling a suite fix(suite): stop suites stalling and agents spinning on them Aug 16, 2026
@Centaurus99 Centaurus99 changed the title fix(suite): stop suites stalling and agents spinning on them fix(suite): stop suites stalling and agents spinning Aug 16, 2026
Comment on lines +333 to +347
Some(suite) => Some(
accept_task_into_suite_query(suite.id, now)
.exec_with_returning(txn)
.await?
.into_iter()
.next()
.ok_or_else(|| {
Error::ApiError(crate::error::ApiError::InvalidRequest(
format!(
"Suite {} was cancelled and cannot accept new tasks",
suite.uuid
),
))
})?,
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should revert this accept_task_into_suite_query back to the original orm form, as the state of the suite is already checked in suite.state.can_accept_tasks() and using update_many here does not save us db connection RTT.

@BobAnkh

BobAnkh commented Aug 16, 2026

Copy link
Copy Markdown
Member

@un-lock-able You should check what we talked about in feishu and reimplement this PR.

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.

3 participants