fix: prevent web ui session loop by removing client-side message id g…#21361
fix: prevent web ui session loop by removing client-side message id g…#21361aadilshaikh123 wants to merge 1 commit intoanomalyco:devfrom
Conversation
…eneration The Web UI was generating message IDs client-side and including them in the API request. This breaks the session loop's monotonic ID ordering assumption, causing the loop to not exit properly and create multiple assistant messages for a single user message. The fix removes client-side message ID generation and lets the server handle it exclusively, maintaining proper ID ordering and preventing the session loop from misfiring. For the optimistic UI, we still generate a temporary ID locally that gets replaced when the server returns the actual message. Fixes: anomalyco#17012
|
The following comment was made by an LLM, it may be inaccurate: I found a related PR that addresses a similar issue: Related PR:
Both PRs touch the same core problem (session loop and message ID ordering), so they may need coordination to avoid conflicts. |
Issue for this PR
Closes #17012
Type of change
What does this PR do?
The Web UI was generating message IDs client-side and including them in the API request. This breaks the session loop's monotonic ID ordering assumption, causing the loop to not exit properly and create multiple assistant messages for a single user message.
The fix removes client-side message ID generation and lets the server handle it exclusively, maintaining proper ID ordering and preventing the session loop from misfiring.
For the optimistic UI, we still generate a temporary ID locally that gets replaced when the server returns the actual message.
How did you verify your code works?
I traced the code flow:
packages/opencode/src/session/prompt.tslastUser.id < lastAssistant.id)Screenshots / recordings
Not applicable - backend fix without UI changes
Checklist