fix: align compaction and stale busy recovery with current OpenCode - #11
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Aligns opencode-loop’s compaction and stale busy/retry recovery behavior with current OpenCode (1.18.15), including native compaction lifecycle tracking and a corrected headless session.summarize fallback payload.
Changes:
- Add message-history-based stale busy recovery that requires a truly completed assistant tail (
time.completed) before early finalization. - Track and serialize loop-initiated compaction using
experimental.session.compacting+session.compacted, and prevent--compact-everyoverlap with the subsequent action. - Add comprehensive deterministic regressions; bump version to
0.5.24and document the release.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/index.js | Implements message-tail validation for stale recovery, compaction lifecycle tracking, and headless summarize payload fixes. |
| scripts/comprehensive-test.mjs | Adds regression coverage for compaction lifecycle, compact/action serialization, and completed-vs-running tail handling. |
| README.md | Updates “Current status” to describe v0.5.24 behavior. |
| package.json | Bumps package version to 0.5.24. |
| package-lock.json | Updates lockfile version metadata to 0.5.24. |
| CHANGELOG.md | Adds v0.5.24 changelog entry summarizing the behavioral changes and test additions. |
| .github/workflows/apply-v0524-pr.yml | Adds a PR workflow to apply/verify/commit the v0.5.24 candidate patch. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+567
to
+575
| const tail = orderedSessionMessages(messages).at(-1) | ||
| const info = tail?.info || tail | ||
| if (!info || info.role !== "assistant") return "incomplete" | ||
| const completed = Number(info?.time?.completed || 0) | ||
| const created = Number(info?.time?.created || 0) | ||
| if (!Number.isFinite(completed) || completed <= 0) return "incomplete" | ||
| const startedAt = Number(active?.startedAt || 0) | ||
| if (startedAt > 0 && completed < startedAt && (!Number.isFinite(created) || created < startedAt)) return "incomplete" | ||
| return "completed" |
| clearActiveRun(sessionID) | ||
| sessionStatuses.delete(sessionID) | ||
| sessionStatusSeenAt.delete(sessionID) | ||
| await appendLoopLog(directory, "compact-finished", { sessionID, job: pending.jobId, resumeAfter: true }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This v0.5.24 candidate follows current OpenCode 1.18.15 source behavior rather than guessing from status alone.
busy/retryagainst the latest chronological assistant message and requiretime.completedbefore early recovery;experimental.session.compactingand the nativesession.compactedevent;--compact-everyso compaction finishes before the actual loop action begins;session.summarizefallback by supplying the required provider/model payload;A temporary PR workflow applies the focused large-file patch and requires npm CI/check/test, Bun import, and npm pack dry-run before committing the verified candidate.