Skip to content

Agent loop runs extra step when client/server clocks are skewed #24183

Closed as duplicate

Description

@Sydius

Description

The agent loop uses message IDs to detect whether a new user prompt arrived mid-response. User message IDs are stamped by the browser; assistant IDs are stamped by the server. When the client and server clocks differ, the browser-stamped user ID can compare as greater than the server-stamped assistant ID even with no new user input, causing the loop to run a spurious extra step. toModelMessagesEffect then produces a message array ending with an assistant message. On llama.cpp with Qwen3 and enable_thinking, this is rejected with: Assistant response prefill is incompatible with enable_thinking. Of course, this may have other effects beyond this, but it's the one that I ran into.

Plugins

none

OpenCode version

1.14.22

Steps to reproduce

  1. Run the OpenCode server and connect from a separate machine whose clock differs from the server's
  2. Send any prompt to a Qwen3 model via llama.cpp with enable_thinking enabled
  3. Observe the error above after the model completes its response

Screenshot and/or share link

No response

Operating System

Arch

Terminal

Ghostty

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 24, 2026
  2. github-actions commented on Apr 24, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of or closely related to an existing issue. Please check:

    • Bug: OpenCode prompt loop continues after finish=stop, triggering prefill error on claude-opus-4-6 #17982: Same symptom (agent loop runs an extra step, last message ends with an assistant turn, triggering a prefill-incompatibility error). That issue attributes the root cause to the prompt loop not gating continuation on finish=stop; your issue identifies clock skew between client and server as a trigger for the same behavior. These may be the same underlying bug or closely related manifestations worth investigating together.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions