Repository navigation
Import host history when a compaction checkpoint is missing it - #215
Conversation
Compaction summarized Cursor's checkpoint in place when a request's Run never finished, when a host history rewrite lived only on the restored snapshot or the call, and when OpenCode 1.x's latest answer was another model's summary or a Cursor error with no tools. Import those cases, keep a finished turn on its checkpoint, and close a Run the rewrite discarded. Co-authored-by: Oleksiy Akimov <[email protected]>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Confidence Score: 5/5
[Medium impact] The reviewed changes appear safe to merge; no actionable issues were found. SummaryCompaction now imports host history when the live checkpoint misses a request or the host has rewritten the conversation.
No actionable issues found. Review was static; tests were inspected but not run.
|
|
@nkoynov Thanks for the repros in #214. Would you be able to test this PR on your OpenCode setup? On 2.x, please check that Please share your OpenCode version and which cases you were able to try. |
|
Tested d7ee20a in a NixOS VM: OpenCode 2.4.3 (opencode2 plugin entry), T3 0.1.14-nightly.20261201.5580, real Cursor key,
The import Runs went out as |
Compaction on a Cursor model summarized the current checkpoint in place when that checkpoint did not hold the host's latest history. The missing turns never entered the summary, and they were not sent again on the next turn. #214 is those three cases.
A request whose Run failed before Cursor checkpointed it stayed in the lost-request record.
summarizeForHostCompactioninsrc/language-model.tssummarized the old checkpoint anyway. The summary replaced the checkpoint, andcarryLostRequestinsrc/lost-request.tsdropped the record because the checkpoint key no longer matched.A host history rewrite restored after restart was also ignored. An ordinary turn honors
postCompactionRebaseandopencodeHistoryRewriteinresolveTurnConversationReset. Compaction only calledawaitHostHistoryRewrite, which is empty after a restart, so it summarized the pre-rewrite conversation.On OpenCode 1.x,
compactionFactsinsrc/plugin.tsskipped every summary before it checked the provider. Another model's compaction summary was ignored and the previous Cursor message counted as the latest answer. A Cursor turn that failed before it ran tools counted the same way.@nkoynov's
1f5b5b7is the right set of checks: import when the lost request still matches the live checkpoint, when a rewrite was restored or sent on the call, and when the latest answer is not Cursor's. This builds on that fix and covers four cases it left open.A history rewrite — still pending, restored from the snapshot, or
opencodeHistoryRewriteon the call — closes a Run that is still waiting on tools, the same way a fresh turn does, and then imports the host transcript. An already-aborted compaction throws before that close, so the waiting Run stays open. A lost request is still judged after a normal drain, so a continuation that already checkpointed its tool results is summarized in place.A lost request causes an import only when its Run never reached
turn_ended.settleLostRequestmarks a finished turn. The record stays so the next turn can still carry the text, and compaction summarizes that checkpoint in place. A finished turn that echoes the same checkpoint bytes no longer remints, and a failed summary no longer clears that checkpoint. When the matching text is missing from the host transcript, the import appends it before the acknowledgement.On OpenCode 1.x, another model's message, including a compaction summary, is that model's latest answer. A Cursor turn that failed with no tool results is skipped. An older step's tool results are not replayed.
test/native-compaction.test.ts,test/plugin.test.ts, andtest/lost-request.test.tscover a lost request on the current checkpoint and on a stale one, a lost request for another conversation, restart with and withoutopencodeHistoryRewrite, repeated compaction, compaction while a Run is pending or already aborted, an unusable summary and its retry, a checkpoint replaced mid-flight, separate sessions and a task session, the 1.x answer cases, warm checkpoint reuse, and continuation after completed tool results.Fixes #214