Skip to content

fix: stop clock-skew response loops - #38213

Closed
quark-zju wants to merge 1 commit into
anomalyco:devfrom
quark-zju:clock-skew
Closed

quark-zju wants to merge 1 commit into
anomalyco:devfrom
quark-zju:clock-skew

Conversation

@quark-zju

@quark-zju quark-zju commented Jul 22, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #24476
Closes #25270

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Fix clock skew. So if the client and server have different clocks, server won't incorrectly respond 0 or >=2 times.

How did you verify your code works?

  1. Added tests.

  2. Deployed this version to a server. Make the server time 5 minutes ahead and 5 minutes behind, check that in both cases the client's message gets one response, and the 2nd client message in a session also gets one response.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@quark-zju quark-zju changed the title fix(opencode): stop clock-skew response loops fix: stop clock-skew response loops Jul 22, 2026
Fix intermittent duplicate assistant responses reproduced in the web UI and
correlated with client/server clock skew.

This can happen in both ways:
- Client clock is ahead: Duplicated responses from the server.
- Client clock is behind: Missing response from the server.

Resolves anomalyco#24476.
Resolves anomalyco#25270.

Agent-Model: gpt-5.6-sol
Agent-Harness: codex
@tdietert

Copy link
Copy Markdown

Additional real-world confirmation: we encountered this on OpenCode 1.18.10. A single user turn produced 699 assistant messages before it was manually aborted; 649 of those messages had finish: "stop" and arrived after the useful response had already completed. This caused substantial unnecessary model API usage.

The behavior is consistent with the ID-ordering termination bug described here, and the parentID check in this PR matches the relationship the loop actually needs to establish.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Model generates identical response twice Web prompts can stop after the first reply when client and server clocks differ

2 participants