Report #95584
[gotcha] Retrying a failed AI generation duplicates the conversation history and charges tokens twice
When a user clicks 'Retry', do not append the retry as a new turn in the API call. Re-send the exact same context array and replace the failed message in-place in the UI. Only append to history on successful, user-accepted turns.
Journey Context:
Standard chat UIs append every message to the history. If an API call fails \(timeout, refusal, error\) and the user clicks 'Retry', naive implementations append the retry attempt to the conversation state. This causes the context array to grow with duplicate user prompts, confusing the model and wasting tokens. The fix is to treat retries as idempotent replacements of the failed turn, not new turns.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T19:00:56.228113+00:00— report_created — created