Skip to content

fix(session): stop replaying compaction recovery as user prompts#18873

Closed
Haohao-end wants to merge 1 commit into
anomalyco:devfrom
Haohao-end:fix/13838-compaction-fake-user-message
Closed

fix(session): stop replaying compaction recovery as user prompts#18873
Haohao-end wants to merge 1 commit into
anomalyco:devfrom
Haohao-end:fix/13838-compaction-fake-user-message

Conversation

@Haohao-end
Copy link
Copy Markdown

Issue for this PR

Closes #13838

Type of change

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

What does this PR do?

This fixes a compaction recovery bug where recovery state could be replayed back to the model as if it were a real user turn.

Before this change, compaction-related replay could introduce fake user-facing prompts such as What did we do so far?, and the auto-compaction continue path also created a synthetic user message. That made the next model turn look like the user was asking for a recap / continuation, which could trigger an unwanted summary instead of normal recovery.

This PR makes three small changes:

  • stop serializing compaction parts into a fake user text prompt
  • keep the auto-compaction recovery note, but mark it as ignored synthetic state instead of a visible user request
  • lift that recovery note into system recovery context during prompt construction

This works because the model no longer sees compaction recovery as fresh user intent. It still gets the recovery instruction needed to continue after compaction, but that instruction is no longer shaped like a real user message.

How did you verify your code works?

Tested locally with:

  • bun test test/session/message-v2.test.ts
  • bun turbo typecheck

I also checked the diff to make sure the change stayed limited to the compaction/replay path and did not alter unrelated message handling.

Screenshots / recordings

N/A

Checklist

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

@github-actions
Copy link
Copy Markdown
Contributor

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

Based on my search, I found one potentially related PR:

PR #13940: fix(compaction): use neutral text for compaction replay message
#13940

This PR appears related as it addresses a similar concern about how compaction replay messages are handled and presented. Both PRs seem to be addressing issues with compaction recovery messaging, though PR #18873 (the current PR) appears to be a more comprehensive fix that stops serializing compaction parts into fake user prompts entirely, while #13940 may have focused on making the replay message more neutral.

The other PRs found (#14826, #16073, #17936) are related to compaction and recovery features but don't appear to directly duplicate the specific issue being fixed here.

@Haohao-end
Copy link
Copy Markdown
Author

Thanks! I checked the duplicate hint.

My change is narrower in implementation shape: it removes the compaction replay fake user prompt path and keeps recovery instructions as ignored synthetic state promoted through system prompt construction, instead of replaying them as user input.

All required checks passed, including unit/e2e/typecheck on Linux and Windows.

@rekram1-node
Copy link
Copy Markdown
Collaborator

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compaction replay injects fake user message "What did we do so far?" causing unwanted summary generation

2 participants