Skip to content

fix(opencode): finish prompt loop by parent link - #40099

Closed
miaojixuezhang wants to merge 1 commit into
anomalyco:devfrom
miaojixuezhang:clock-skew-loop
Closed

fix(opencode): finish prompt loop by parent link#40099
miaojixuezhang wants to merge 1 commit into
anomalyco:devfrom
miaojixuezhang:clock-skew-loop

Conversation

@miaojixuezhang

Copy link
Copy Markdown

Issue for this PR

Closes #40098

Type of change

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

What does this PR do?

A finished assistant turn is linked to its user message by parentID. Comparing their IDs assumes the client and server clocks agree; when a client clock is ahead, the prompt loop can run the completed turn again. This uses the parent link instead and adds a regression test with deliberately reversed ID order.

How did you verify your code works?

  • Regression test times out before the fix and passes after it.
  • bun test test/session/prompt.test.ts — 57 pass, 1 skip.
  • bun typecheck from packages/opencode.
  • Prettier check on both changed files.

Screenshots / recordings

Not applicable; this is a prompt-loop fix.

Checklist

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

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search results, I found one highly relevant related PR:

Potential Related PR:

This PR seems directly related to the current PR #40099, as both fix the prompt loop logic by switching from ID-based comparison to parent-link-based logic. However, since PR #38387 already exists, you may want to verify if:

  1. This is a regression that needs fixing again, or
  2. The fix from fix(session): end the turn loop by reply parent, not message ID order #38387 needs adjustment/expansion

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant