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

The Free Budget Vanished in 90 Minutes: Debugging a Token Ledger That Charged Every Retry

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

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

Задача

Free usage allowance was depleted unexpectedly while users interacted normally with a chat UI.

Результат

The ledger refactor prevented repeated charges, eliminated duplicate answers, and stabilized balance tracking, restoring correct usage accounting.

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

  • Identify symptoms visible in UI and requests
  • Check outbound request count per user action
  • Verify idempotency key usage
  • Inspect prompt size and context reuse
  • Ensure single event listener for keydown/submit
  • Confirm live region updates are outside stream loop
  • Audit abort handling and ledger settlement
  • Refactor code to use a ledger module with createLedger, begin, settle, and summary functions
  • Add idempotency key to each request
  • Ensure ledger writes only on attempt start and settlement
  • Test with multiple users and edge cases

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

Balance drops faster than the transcript grows

Источник

Retries sent without an idempotency key

Источник

Ledger.ts — the single source of truth for attempts and usage

Источник

  • Дата записи: 2026-10-27T13:26:17.403Z