Skip to content

A failed job finds its way back to the queue - #258

Merged
WaylandYang merged 4 commits into
devfrom
fix/failed-jobs-return-to-the-queue
Sep 3, 2026
Merged

A failed job finds its way back to the queue#258
WaylandYang merged 4 commits into
devfrom
fix/failed-jobs-return-to-the-queue

Conversation

@WaylandYang

Copy link
Copy Markdown
Contributor

Fixes #216.

A failed job could only run again through the object it belonged to; bootstrap_ontology, adjudicate_entities and the rest had no way back, and since #201 an out-of-credit batch fails on the first attempt — five hundred documents, one click each after the top-up.

Requeue by scope. jobs::requeue_failed(RequeueScope { kb_id, kind, failed_since }) puts failed rows back (attempts = 0, due now); handlers are idempotent, which is what orphan recovery already relies on. The knowledge base is resolved from the payload — document_id, source_id or kb_id — so another base's jobs are never touched, and jobs without a base move only in the unscoped call. Two endpoints: POST /kbs/{id}/jobs/requeue (Editor) and POST /jobs/requeue (admin, for system alerts); GET /kbs/{id}/jobs/failed counts.

The alert carries the action. llm.out_of_credit and llm.unreachable groups show "Run those again", scoped to the group's base and to jobs that failed since the group's earliest alert — top up, click, the batch resumes. KB settings shows "N failed jobs · Run again" for every other kind of failure. No queue page.

Test: a_failed_job_finds_its_way_back — scope by base (document, source and base-level payloads), by kind, by time window; done rows stay done; a system job moves only unscoped.

0005 carries a revision note.

🤖 Generated with Claude Code

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@WaylandYang
WaylandYang merged commit 4529457 into dev Sep 3, 2026
3 checks passed
@WaylandYang
WaylandYang deleted the fix/failed-jobs-return-to-the-queue branch September 3, 2026 11:04
@WaylandYang WaylandYang mentioned this pull request Sep 3, 2026
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.

A failed job has no way back into the queue

1 participant