Skip to content

Clock skew between client and server breaks prompt loop and message rendering #14236

@MakonnenMak

Description

@MakonnenMak

Description

When the client and server clocks are out of sync (e.g. browser on a local machine, server on a
remote host), client-generated message IDs sort after server-generated assistant IDs because IDs are
timestamp-based. This causes two bugs:

  1. Prompt loop never exits — the exit check compares user vs assistant message IDs by sort order.
    With clock skew, the user ID is always "newer" so the condition never triggers, causing 15+ loop
    iterations instead of 1.
  2. Assistant messages not rendered — SessionTurn only scans forward from the user message index to
    find assistant replies. With skewed IDs, the assistant sorts before the user message and is never
    found.

I was trying to use opencode on my coder.com env and i would basically see no responses in web ui while llm usage was going up, but TUI was completely fine

Expected behavior
The prompt loop should exit after one iteration and assistant messages should render regardless of
clock differences between client and server.

Plugins

None

OpenCode version

1.2.6

Steps to reproduce

  1. Run the OpenCode server on a remote host where the clock differs from the client browser by
    several seconds
  2. Send a prompt
  3. Observe the prompt loop running many iterations and assistant messages not appearing in the UI

Screenshot and/or share link

No response

Operating System

Linux

Terminal

No response

Metadata

Metadata

Assignees

Labels

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

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions