Skip to content

[BUG]: Revert state not cleaned before compaction causes ghost messages; aborted compaction leaves dangling partial summary #30806

Closed

Description

Description Two bugs in compaction boundary state handling. Bug 1: Revert state + compaction = ghost messages compaction.ts:353-356 鈥?when compaction.process() validates the parent is a user message, if revert state exists with a pending revert, filterCompactedEffect() may return ghost messages that don't properly interact with compaction. The test revert-compact.test.ts covers cleanup when done properly, but any code path that calls compaction without first clearing revert state will hit this. Bug 2: Aborted compaction leaves dangling partial summary compaction.ts:439-459 鈥?if compaction is aborted after the processor creates the summary assistant message (mode: "compaction", summary: true) but before the LLM call completes, a partial summary message with summary: true remains in the database with no actual content. This can confuse downstream filterCompacted() and latest() calls. Focused follow-on to #30376. Suggested fix: (Bug 1) force revert cleanup as a precondition in compaction.process(). (Bug 2) add cleanup that deletes any summary:true message without a finish reason on compaction abort. ### OpenCode version

main

Steps to reproduce 1. Create a session with revert state pending 2. Trigger compaction (fill context to overflow) 3. filterCompacted returns ghost messages 4. Main loop picks wrong "latest" message

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions