Part of a short series on the features in the Delivery Desk demo, a parcel delivery desk run by agents on one durable log, built on Laser SDK. The first post, Killing agents in a delivery desk demo, covers crash and resume. This one covers dead letters and redrive.
The failure
Pick SMS gateway down from the header. The SMS gateway now rejects the next notify step, the step where the customer agent tells people their parcel is late.
Retrying forever would block the agent. Dropping the message would mean a customer is never told. The desk does neither.
Retry, then dead-letter
Every agent is started with a retry policy and a dead_letter hook:
handle = laser.spawn_agent(name, C.INBOX, handler, respond_on=C.INBOX, capabilities=C.SKILLS[name], retry_max_attempts=C.RETRY_ATTEMPTS, retry_base_delay_ms=C.RETRY_DELAY_MS, dead_letter=dead_letter) If the handler raises, the SDK tries the task again. When the retries run out, the runtime gives up on the task and calls the hook. In the demo the customer agent retries the notify step three times before that happens.
Parking it on the desk
The hook receives the message and a capsule describing the failure: the reason, the number of attempts, the detail, and the original payload and source. The demo parks all of that in KV, where the desk shows it under Dead letters, and writes a dead_letter event to the log:
async def dead_letter(message, capsule, publish_error=None): """The runtime gave up on a task: park it in KV for the desk to redrive.""" body = body_json(message) or {} exc = body.get("exception") or {} key = ls.mint_ulid() await put_json(fleet.dlq, key, { "agent": name, "incident": exc.get("id", ""), "van": exc.get("van", ""), "reason": capsule.get("reason"), "attempts": capsule.get("attempts"), "detail": capsule.get("detail") or "", "source": bytes(capsule.get("source") or b"").hex(), "payload": bytes(capsule.get("payload") or b"").hex(), "state": "parked"}) Fix and redrive
Fix and redrive clears the fault and calls laser.redrive_dead_letter(...) with the parked capsule. The runtime re-reads the original record and publishes it again, and the customer agent handles it as if it were new. The customers get their messages.
One more case is handled. While the task sat in the dead-letter list, the workflow that sent it may have given up. When a dead letter is redriven, dispatch checks for that and resumes the workflow under the same run id. The workflow's journal skips the steps already done, so assess and replan are not run twice; only the notify step runs again.
Why this matters
Agents call things that fail: SMS gateways, payment APIs, model providers. A dead-letter list turns "the agent got stuck" into an item a person can see, fix and send through again, with the original record intact and nothing done twice.
Try it
You need Python 3.11+ and Docker.
git clone https://github.com/laserdata/laser-delivery-desk cd laser-delivery-desk docker compose up -d python3 -m venv .venv && . .venv/bin/activate pip install -e . python -m fleet.server The code is at laserdata/laser-delivery-desk, Laser SDK is at laserdata/laser-sdk, and the docs are at docs.laserdata.com/laser-sdk.

