Skip to content

fix(session): use idle framing when a checkpoint rebuild follows a completed stop - #2061

Open
YOMXXX wants to merge 1 commit into
XiaomiMiMo:mainfrom
YOMXXX:fix/checkpoint-idle-resume
Open

fix(session): use idle framing when a checkpoint rebuild follows a completed stop#2061
YOMXXX wants to merge 1 commit into
XiaomiMiMo:mainfrom
YOMXXX:fix/checkpoint-idle-resume

Conversation

@YOMXXX

@YOMXXX YOMXXX commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1915 (part 1). After a finite task completes, a checkpoint rebuild unconditionally reinjected "Pick up the last task as if the break never happened" plus resume reminders, so the main agent re-verified already-finished work → token growth → repeated writers/rebuilds → keep-alive loop.

Root cause: packages/opencode/src/session/checkpoint.ts renderRebuildContext() Section 10 always appended the hard resume text, and Section 11 used a resume-oriented stopReminder() for assistant + finish === "stop". No idle/done branch.

Fix: gate the resume framing on the tail:

  • Compute done = lastMessageInfo?.role === "assistant" && lastMessageInfo.finish === "stop".
  • Section 10: when done, use an idle framing ("if it fulfilled the user's request, do not reopen or re-verify completed work — wait for the user's next input"); otherwise keep the resume text.
  • Section 11: assistant/stop → new idleReminder() (do-not-reopen + progress.md guidance so a genuinely mid-task / truncated / cancelled agent still knows where to judge); tool-callsautonomousLoopReminder() (unchanged); tooltoolResultContinueReminder() (unchanged).
  • Removed the now-unused stopReminder.

Test Plan

  • New tests: assistant/stop → no "Pick up the last task", contains "wait for the user"; assistant/tool-calls → keeps resume framing.
  • Updated checkpoint-rebuild-v3.test.ts (its old assertion referenced the removed stopReminder text).
  • bun test test/session/checkpoint-render-verify.test.ts test/session/checkpoint-rebuild-v3.test.ts — 22 pass; bun typecheck clean.

Notes

  • Issue's suggested parts 2 (writer idle/done rules) and 3 (LastMessageInfo/rebuildMode) are follow-ups; part 1 alone stops the reopen loop per the issue.

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.

Checkpoint rebuild reinjects hard resume after completed work, causing main-agent keep-alive loop

1 participant