A failure queue is part of the workflow
A workflow can finish running while leaving its actual job unfinished. A request times out. A document cannot be parsed. A required field is missing. If the next step simply receives an empty value, the failure can disappear into something that looks like an ordinary result.
Before adding automatic retries, decide where unfinished work belongs. A small failure queue gives that work a visible state and a reason someone can act on. This article was drafted with AI assistance.
Keep the task and its failure together
Consider a hypothetical newsletter workflow. Its job is to prepare an outline for review. A dependency times out before the outline is available.
“Timeout” is useful diagnostic information, but it does not identify the work still owed. The record also needs a stable job ID, the requested work and its current state. Keep those together so a reviewer can see what failed without reconstructing the task from scattered logs.
For the local teaching example accompanying this article, the record starts like this:
id: draft-7
payload: Prepare a hypothetical newsletter outline
state: pendingWhen the dependency fails, the record becomes needs_review. Its reason is dependency_timeout. The original payload stays in place. Nothing in this transition claims that an outline was produced or delivered.
Use a short reason code for routine handling. If you need diagnostic logs, keep them separately with appropriate access. Do not put credentials, private customer messages or a full provider response into a queue merely because it is convenient.
Make recovery an explicit decision
The example uses a small SQLite table with a primary key for each job. Adding the same ID twice fails rather than overwriting the original work. A failure transition is allowed only from pending; resolution is allowed only from needs_review.
Get AI Automation Blueprint’s stories in your inbox
Join Medium for free to get updates from this writer.
Resolution also requires a nonempty note. In the test, the note says: “Reviewed locally; no delivery attempted.” The record retains its timeout reason after resolution, so the earlier failure is still visible.
That note has a limited meaning. It records a review decision. It is not evidence of publication, inbox delivery or a successful network retry. A real workflow should define the evidence required for those outcomes separately.
Sometimes the appropriate decision is to retry. Sometimes it is to correct the input, prepare the work another way or cancel it with a reason. The queue should make that choice visible instead of treating another attempt as inevitable.
Test the uncomfortable paths
The example was tested locally with Python’s unittest runner. All three tests passed:
- A failed task kept its payload, review state and reason after the database connection was closed and reopened.
- A blank resolution note was rejected. A valid note resolved the task while preserving its original failure reason.
- A duplicate ID and a premature resolution attempt were rejected without destroying the original record.
These are observed results from an isolated example. No newsletter was sent, no external service was called and no live customer workflow was exercised. The source and test output are preserved with this draft.
The tests matter because a normal successful run would not reveal whether failed work survives reopening. It would not reveal whether a duplicate request can replace the original task. Test the transitions that could lose or mislabel work, including the ones you hope never happen.
Know what this small queue leaves out
This example is a starting point for reasoning about state. It does not implement worker claims, crash recovery during an external action, retry backoff, access controls or a complete audit log. It stores a latest resolution note rather than a history of every decision.
For a production workflow, a crash after sending a request can leave the result uncertain. Do not assume that uncertainty means nothing happened. Reconcile the destination before retrying an action that might already have completed.
Start by answering a practical question: if the next dependency fails, where will you find the unfinished task? Then define who can resolve it and what evidence makes the result trustworthy. A workflow is easier to review when its unfinished work has somewhere honest to stay.









