Skip to content

fix: prevent web ui session loop by removing client-side message id g…#21361

Closed
aadilshaikh123 wants to merge 1 commit into
anomalyco:devfrom
aadilshaikh123:bugfix/main
Closed

fix: prevent web ui session loop by removing client-side message id g…#21361
aadilshaikh123 wants to merge 1 commit into
anomalyco:devfrom
aadilshaikh123:bugfix/main

Conversation

@aadilshaikh123
Copy link
Copy Markdown

@aadilshaikh123 aadilshaikh123 commented Apr 7, 2026

Issue for this PR

Closes #17012

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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:

  1. Reviewed the session loop logic in packages/opencode/src/session/prompt.ts
  2. Confirmed that monotonic ID ordering is required for the loop exit condition (lastUser.id < lastAssistant.id)
  3. Verified that client-side ID generation was breaking this ordering
  4. Confirmed the fix maintains server-side ID generation while keeping optimistic UI working with temporary IDs

Screenshots / recordings

Not applicable - backend fix without UI changes

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…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
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2026

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.

@rekram1-node
Copy link
Copy Markdown
Collaborator

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:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web sessions can loop indefinitely when user message IDs are generated on the client

2 participants