Developers / SDKs

Recover after a restart

Save the request and progress so a new worker retrieves the same task, including the receipts for its actions, without submitting a second change.

Save before sending

Use the client configured in the quickstart. Implement a storage callback that saves the checkpoint in your application's durable storage, then call prepare and submit:

Python
# Use the client configured in the quickstart.
# save_checkpoint is your application's durable storage callback.
task = deixic.tasks.prepare(
    channel_id="company",
    body="Summarize these notes: Access review found two former contractors with GitHub admin. Next: remove their access.",
    idempotency_key="notes-event-001",
    on_checkpoint=save_checkpoint,
)
task.submit()
result = task.wait(timeout=60)

TypeScript
// Use the client configured in the quickstart.
// saveCheckpoint is your application's durable storage callback.
const task = await deixic.tasks.prepare({
  channelId: "company",
  body: "Summarize these notes: Access review found two former contractors with GitHub admin. Next: remove their access.",
  idempotencyKey: "notes-event-001",
  onCheckpoint: saveCheckpoint,
});
await task.submit();
const result = await task.wait({ timeoutMs: 60_000 });

The callback runs before submission and after acceptance or consumed event pages. Storage failures propagate to your application. Keep callback effects idempotent across restarts and failed saves.

Resume observation

Reload the saved checkpoint in a new worker with the same organization, workspace, and service URL. Use resume to observe the accepted task without submitting another request:

Python
# Reload the checkpoint from your storage in a new worker.
task = deixic.tasks.resume(saved_checkpoint, on_checkpoint=save_checkpoint)
result = task.wait(timeout=60)

TypeScript
// Reload the checkpoint from your storage in a new worker.
const task = deixic.tasks.resume(savedCheckpoint, { onCheckpoint: saveCheckpoint });
const result = await task.wait({ timeoutMs: 60_000 });

wait follows the matching turn's progress and retrieves its final answer and referenced receipts. A preliminary response remains in progress until the turn completes.

Recover a lost submission response

An unacknowledged checkpoint means the submission response was lost. Explicitly call task.replay() in Python or await task.replay() in TypeScript. Replay preserves the original body and idempotency key and refuses an already accepted task. Then call wait.

For the installed account-brief example, use:

Python · Shell
python -m deixic.examples.account_brief replay account-brief.json
python -m deixic.examples.account_brief resume account-brief.json

TypeScript · Shell
npx --no-install deixic-account-brief replay account-brief.json
npx --no-install deixic-account-brief resume account-brief.json

Keep the original checkpoint and trigger ID throughout recovery. Starting with a new key creates a different request.

Handle observation timeouts

A timeout stops local observation; remote work continues until it finishes or is explicitly interrupted. Resume observation with the checkpoint. Use controls.interrupt only when your application explicitly decides to stop remote work.

Read requests reconnect after transport failures within the configured observation budget. The SDK does not retry a task mutation after a transport failure. Handle an unfinished result rather than submitting again.

Choose recovery for the failure

FailureRecovery
Worker killed after acceptanceResume the saved accepted turn. Do not submit again.
Accepted submission response lostExplicitly replay the original unacknowledged request and key.
Observation disconnectsReconnect bounded reads or resume; retain the checkpoint.
Storage fails before submissionRepair storage before explicitly submitting. No network mutation was sent.
Storage fails after acceptancePreserve the checkpoint. Replay explicitly if it remains unacknowledged.
Worker switches languageResume the same Python/TypeScript checkpoint with the same tenant and URL.
Approval history is unavailableReview in Deixic; no approval request is invented.

Protect checkpoints

Checkpoints use the shared deixic.task.v1 format with decimal-string cursors. They contain the task body and no SDK credential. Protect them as company data and use one observer and storage writer per checkpoint.

The SDK rejects a checkpoint from a different organization, workspace, or service URL. A saved checkpoint records request and observation coordinates; it does not establish authorization or task completion.