anomalyco / anomalyco/opencode
Prompt loop may repeat a completed turn when client clock is ahead
@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
- Store a user message with ID
msg_ffff_client_clock. - Store a finished assistant message with ID
msg_0000_server_clockandparentIDset to that user ID. - Call
SessionPrompt.loop()with no LLM server available. - 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.