Model in BUILD mode does not have enough context to continue after compaction #1999

Open
opened 2026-02-16 17:33:41 -05:00 by yindo · 5 comments
Owner

Originally created by @agladysh on GitHub (Oct 8, 2025).

Originally assigned to: @thdxr on GitHub.

Compaction summaries are too basic, and do not include context sufficient information for the model to continue work when compaction happens in BUILD mode, leading to nonsensical changes and wasted work.

On compaction, ask the model to prepare a detailed handoff document for it to continue the work after the context window reset. Ask the model to prepare the list of documents and files defining the work being done, as well as files that were or would be changed during the work. Include these files and git status -sbu in the context after compaction.

P.S. I have a suspicion that AGENTS.md is not included in the context after compaction (it should), but I did not verify it rigourously.

Originally created by @agladysh on GitHub (Oct 8, 2025). Originally assigned to: @thdxr on GitHub. Compaction summaries are too basic, and do not include context sufficient information for the model to continue work when compaction happens in BUILD mode, leading to nonsensical changes and wasted work. On compaction, ask the model to prepare a detailed handoff document for it to continue the work after the context window reset. Ask the model to prepare the list of documents and files defining the work being done, as well as files that were or would be changed during the work. Include these files and `git status -sbu` in the context after compaction. P.S. I have a suspicion that AGENTS.md is not included in the context after compaction (it should), but I did not verify it rigourously.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 8, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #2945: Session automatically compacted, destroying the entire working context - describes same issue where compaction destroys working context in build mode
  • #2234: compact causes llm to forget convo - model forgets conversation context after compaction, leading to starting fresh
  • #940: Preload instructions after /compact - requests automatic preloading of instructions after compaction to maintain context
  • #1990: Add User Controls for Context Management - broader feature request for context management that could address compaction issues

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Oct 8, 2025): This issue might be a duplicate of existing issues. Please check: - #2945: Session automatically compacted, destroying the entire working context - describes same issue where compaction destroys working context in build mode - #2234: compact causes llm to forget convo - model forgets conversation context after compaction, leading to starting fresh - #940: Preload instructions after /compact - requests automatic preloading of instructions after compaction to maintain context - #1990: Add User Controls for Context Management - broader feature request for context management that could address compaction issues Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Oct 8, 2025):

P.S. I have a suspicion that AGENTS.md is not included in the context after compaction (it should), but I did not verify it rigourously.

It is included

@rekram1-node commented on GitHub (Oct 8, 2025): > P.S. I have a suspicion that AGENTS.md is not included in the context after compaction (it should), but I did not verify it rigourously. It is included
Author
Owner

@rekram1-node commented on GitHub (Oct 8, 2025):

Compaction summaries are too basic, and do not include context sufficient information for the model to continue work when compaction happens in BUILD mode, leading to nonsensical changes and wasted work.

yeah the prompt could use some work

@rekram1-node commented on GitHub (Oct 8, 2025): > Compaction summaries are too basic, and do not include context sufficient information for the model to continue work when compaction happens in BUILD mode, leading to nonsensical changes and wasted work. yeah the prompt could use some work
Author
Owner

@tuxillo commented on GitHub (Dec 21, 2025):

P.S. I have a suspicion that AGENTS.md is not included in the context after compaction (it should), but I did not verify it rigourously.

It is included

there must be some use cases where it is not because i find myself reminding it over and over that there is an AGENTS.md in the root of the project 😄

@tuxillo commented on GitHub (Dec 21, 2025): > > P.S. I have a suspicion that AGENTS.md is not included in the context after compaction (it should), but I did not verify it rigourously. > > It is included there must be some use cases where it is not because i find myself reminding it over and over that there is an AGENTS.md in the root of the project 😄
Author
Owner

@maxeonyx commented on GitHub (Jan 12, 2026):

@agladysh I have a PR which will support custom prompts for compaction. I have been having great success with the following custom prompt (although, I have mostly used it with Opus 4.5, so bears testing for other models.)

---
description: Compact & hand over
compact: true
---

Curate a hand-over note from this conversation, so that a new agent can take over and continue aiding the user.

The new agent will have no context except what you provide in the note - so focus on informing them of everything they will need (while leaving out anything they won't need).

Pay attention to the vibe, the exact workflow. Record some interactions or habits that went well - put the abridged examples in the note. Show by example!

Make sure that the note contains all of:

- The goal of this work, keeping specific wording by the user as much as possible.
- The history of the conversation & work, especially open threads or things that may be useful going forward.
- Specific commands that will be useful, specific filenames that will be useful, other specific details.
- Briefly, any issues that were encountered and the solution, to save the new agent doing any debugging again.

If the last message was one from the user, please include it exactly, at the very end of the note.

Focus on including details that would not be recoverable, or that would take time to do so, but feel free to leave out anything that the new agent would easily discover themselves, and encourage them to do so.

Take the time and space to do a good job of representing the work & demonstrating to the new agent how to seamlessly continue it.
@maxeonyx commented on GitHub (Jan 12, 2026): @agladysh I have [a PR](https://github.com/anomalyco/opencode/pull/4149) which will support custom prompts for compaction. I have been having great success with the following custom prompt (although, I have mostly used it with Opus 4.5, so bears testing for other models.) ``` --- description: Compact & hand over compact: true --- Curate a hand-over note from this conversation, so that a new agent can take over and continue aiding the user. The new agent will have no context except what you provide in the note - so focus on informing them of everything they will need (while leaving out anything they won't need). Pay attention to the vibe, the exact workflow. Record some interactions or habits that went well - put the abridged examples in the note. Show by example! Make sure that the note contains all of: - The goal of this work, keeping specific wording by the user as much as possible. - The history of the conversation & work, especially open threads or things that may be useful going forward. - Specific commands that will be useful, specific filenames that will be useful, other specific details. - Briefly, any issues that were encountered and the solution, to save the new agent doing any debugging again. If the last message was one from the user, please include it exactly, at the very end of the note. Focus on including details that would not be recoverable, or that would take time to do so, but feel free to leave out anything that the new agent would easily discover themselves, and encourage them to do so. Take the time and space to do a good job of representing the work & demonstrating to the new agent how to seamlessly continue it. ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1999