Skip to content

Prompt loop may repeat a completed turn when client clock is ahead #40098

Closed as not planned

Description

@miaojixuezhang

Description

The legacy prompt loop treats a finished assistant as newer only when lastUser.id < lastAssistant.id. These IDs can be generated on different devices and contain local time. If a web or mobile client clock is ahead of the server, a finished assistant can correctly reference the user through parentID but sort lower, so loop() starts another provider turn and may produce a duplicate response.

Plugins

None required.

OpenCode version

Current dev at 32f278b48f1a495611165d8a9f1ace0b512933e2 (packages/opencode 1.18.11).

Steps to reproduce

  1. Store a user message with ID msg_ffff_client_clock.
  2. Store a finished assistant message with ID msg_0000_server_clock and parentID set to that user ID.
  3. Call SessionPrompt.loop() with no LLM server available.
  4. The loop does not exit and the regression test times out while entering the provider path.

The parent link is the reliable turn relationship; ID ordering is not reliable across clocks.

Screenshot and/or share link

Not applicable; reproduced with a focused unit test.

Operating System

Observed from a mobile web client and reproduced in the test suite on macOS.

Terminal

Not terminal-specific.

Activity

  1. github-actions commented on Aug 1, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. github-actions commented on Oct 1, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions