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 into
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. |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
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