anomalyco / anomalyco/opencode

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

Open
#40,098 1 comment 0 reactions 1 assignee View on GitHub

@rekram1-node is already working on this.

Since Aug 1, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.