Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Practitioner Notes: Idempotent Handoffs Before You Add an LLM to a Custom Workflow

Описание и применение

Внедрение атомарной записи входящих событий, очереди outbox и единого поля статуса обеспечивает отсутствие дублирования сообщений, согласованность данных CRM и экономию токенов LLM при повторных попытках.

Задача

Inbound events and outbound replies can be processed or sent multiple times, causing duplicate messages, inconsistent CRM data, and wasted LLM tokens.

Результат

Implementing idempotent inbound handling, outbox delivery, and partial write tracking reduces duplicate messages, ensures consistent CRM data, and saves LLM tokens during retries.

Рабочий процесс

  • Record inbound event with a unique key and insert-if-absent to detect duplicates.
  • Enqueue a job to perform slow work, including LLM calls, after the event is recorded.
  • Insert outbound replies into an outbox with a deterministic ID derived from the approved draft.
  • Deliver messages from the outbox only if status is pending, updating status to sent and storing provider_id.
  • Track handoff status on the CRM record with values received, matched, owned, replied.
  • Maintain a dead‑letter list for events that fail repeatedly and review them manually.
  • Reuse stored LLM outputs on job retries instead of generating new drafts.

Доказательства

Before you wire an LLM into production messaging, make the handoffs on both sides of it boring: inbound events processed once, outbound replies sent once, and partial writes impossible to miss.

Источник

The insert-if-absent must be atomic (a unique index is enough). Do the slow work, including the LLM call, in the queued job, not in the webhook handler.

Источник

The outbox row id is derived from the approved draft, so approving twice or retrying delivery cannot create a second message.

Источник

Write a single handoff_status field on the CRM record: received, matched, owned, replied.

Источник

In our 72-hour audits, this list usually generates more findings than the prompts do.

Источник

  • Дата записи: 2026-10-09T04:41:11.782Z