Skip to content

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

Open
aadilshaikh123 wants to merge 1 commit intoanomalyco:devfrom
aadilshaikh123:bugfix/main
Open

fix: prevent web ui session loop by removing client-side message id g…#21361
aadilshaikh123 wants to merge 1 commit intoanomalyco: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.

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

Labels

None yet

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

1 participant