Skip to content

How should my dispatcher handle one malformed task that crashes every worker attempt?

Move repeatedly failing local commands into a quarantine state with their evidence and an explicit repair owner. Do not endlessly return the same malformed item to the front of the queue. Distinguish deterministic application failure from uncertain AISwapLab acceptance before deciding what can be safely replayed.

MAKE API WORK RECOVERABLEAISwapLab team · Editorial methodUpdated 2 min read
Open API documentationExplore 67 Image SkillsPrivate keys · Explicit credit approval
Article workflow: Classify the failure boundary; Bound automatic attempts; Repair through a reviewed command.
Workflow diagram: Classify the failure boundary → Bound automatic attempts → Repair through a reviewed command. Read the article for evidence and limits.

A bad item should remain inspectable

A serialization bug, missing migration or unsupported local payload version can crash a worker before meaningful processing begins. Automatic retries cannot repair every defect. Quarantine prevents one item from dominating dispatch while preserving the action for diagnosis.

What to do next

  1. 01

    Classify the failure boundary

    Record whether the command failed before dispatch, during an uncertain remote call or while processing a known remote job. Only classify a deterministic local defect after checking that remote work was not silently accepted.

  2. 02

    Bound automatic attempts

    Keep attempt count, first failure and last failure on the local delivery record. After your configured policy is reached, quarantine the item rather than deleting it, generating a new request identity or blocking the entire queue.

  3. 03

    Repair through a reviewed command

    Inspect and repair the underlying application defect, then replay using the preserved approved snapshot and identity where valid. Require a new approval if the repair changes creative inputs or spending intent.

A concrete example

Illustrative example: one old command has an unsupported payload version. After two deterministic pre-dispatch failures under the application's policy, it enters quarantine. Other commands continue, and an operator repairs the decoder before replaying that same action.

Run the local counterexample

Local runtime fixture, executed November 16, 2026. No AISwapLab request, payment or model generation was made.

Recorded runtime: Python 3.12.10; SQLite 3.49.1. Run the complete script below using that runtime or record the version and changed behavior in your own environment. The script uses synthetic data and temporary resources only.

python
import sqlite3,json
c=sqlite3.connect(':memory:')
c.execute('CREATE TABLE command(id INTEGER,payload TEXT,state TEXT)')
c.executemany('INSERT INTO command VALUES(?,?,?)',[(1,'{"model":"fixture"}','pending'),(2,'{broken','pending'),(3,'{"model":"other"}','pending')])
try:
    c.execute("SELECT id,json_extract(payload,'$.model') FROM command ORDER BY id").fetchall()
    unsafe='unexpectedly completed'
except sqlite3.OperationalError as e:unsafe=type(e).__name__+': '+str(e)
safe=c.execute("SELECT id,CASE WHEN json_valid(payload) THEN json_extract(payload,'$.model') ELSE NULL END FROM command ORDER BY id").fetchall()
changed=c.execute("UPDATE command SET state='quarantined' WHERE NOT json_valid(payload)").rowcount
print(json.dumps({'unprotectedQuery':unsafe,'guardedQuery':safe,'quarantinedRows':changed,
  'remainingPendingIds':[r[0] for r in c.execute("SELECT id FROM command WHERE state='pending' ORDER BY id")]}))
c.close()

Actual output from this run

json
{
  "unprotectedQuery": "OperationalError: malformed JSON",
  "guardedQuery": [
    [
      1,
      "fixture"
    ],
    [
      2,
      null
    ],
    [
      3,
      "other"
    ]
  ],
  "quarantinedRows": 1,
  "remainingPendingIds": [
    1,
    3
  ]
}

Use the result within its scope

One malformed payload made the unprotected fetch fail. The guarded CASE exposed valid values while leaving the invalid row unresolved, and a separate update quarantined only that row. Validate local command data before applying JSON extraction across a batch; quarantine must preserve evidence, not silently transform malformed creative input into a different approved request.

The malformed text is synthetic and never sent to AISwapLab. SQLite JSON validation does not establish model-schema validity or prove that a command was never previously dispatched.

Before you call it ready

  • Quarantine retains the original snapshot.
  • Remote uncertainty has a separate path.
  • Other queue items continue processing.

When to stop or choose another method

Stop automatic replay when you cannot establish whether the failure preceded remote dispatch; investigate the accepted-work evidence first.

Sources

One task. A recoverable workflow.

Check the contract, approve the quote and retain the job.

Open API documentation