Report #84602
[gotcha] Regenerate/Retry buttons append duplicate messages and break the LLM context window
Implement retry as a branch/replace operation on the existing message ID in the state tree, rather than appending a new user message \+ assistant message pair to the history array sent to the LLM.
Journey Context:
When an LLM gives a bad answer, users click 'Retry'. A naive implementation appends the user's prompt again to the API call to 'remind' the AI, or appends a new assistant response. This inflates the context window with duplicates, confusing the LLM \(it sees the same question twice and might hallucinate or repeat the bad answer\). The correct pattern is to mutate the specific message node in the conversation tree and resend the history up to that point, treating the new generation as a sibling branch.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T00:35:44.721085+00:00— report_created — created