Auto-compaction causes the subagent to lose its original context, possibly the system prompt as well #4035

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

Originally created by @gasatrya on GitHub (Dec 31, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

I’m honestly frustrated, this is the second time it has happened.

I have a QA Specialist subagent whose prompt explicitly instructs it to perform only QA-related tasks. However, due to auto-compaction, it loses the original context provided by the main agent. As a result, it suddenly starts reading the planned features document and working on the next phase without my permission.

This is problematic because the subagent was specifically designed to handle QA tasks, not to build or implement new features.

How can I prevent this from happening again in the future?

OpenCode version

1.0.218

Steps to reproduce

Must have main again and subagent.

Screenshot and/or share link

Image Image

Operating System

WSL 2

Terminal

Windows Terminal

Originally created by @gasatrya on GitHub (Dec 31, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description I’m honestly frustrated, this is the second time it has happened. I have a QA Specialist subagent whose prompt explicitly instructs it to perform only QA-related tasks. However, due to auto-compaction, it loses the original context provided by the main agent. As a result, it suddenly starts reading the planned features document and working on the next phase without my permission. This is problematic because the subagent was specifically designed to handle QA tasks, not to build or implement new features. How can I prevent this from happening again in the future? ### OpenCode version 1.0.218 ### Steps to reproduce Must have main again and subagent. ### Screenshot and/or share link <img width="1404" height="634" alt="Image" src="https://github.com/user-attachments/assets/f307f3b7-45dc-4020-a99c-aeef2a75de20" /> <img width="1266" height="674" alt="Image" src="https://github.com/user-attachments/assets/755b1f2c-8864-4cde-8d06-290ec48bd099" /> ### Operating System WSL 2 ### Terminal Windows Terminal
yindo added the windowsbug labels 2026-02-16 17:42:22 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 31, 2025):

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

  • #4483: Subagents inappropriately inherit main agent instructions from CLAUDE.md/AGENTS.md
  • #3031: Model in BUILD mode does not have enough context to continue after compaction
  • #4102: Epic: Compaction Update (addresses context loss and rules preservation during compaction)
  • #5934: Session Todo-list is forgotten after compaction (related context loss issue)

The core issue appears to be that auto-compaction may be incompletely preserving the subagent's system prompt and specialized instructions. Issues #4483 and #4102 directly address similar problems where context or instructions are lost after compaction.

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

@github-actions[bot] commented on GitHub (Dec 31, 2025): This issue might be a duplicate of existing issues. Please check: - #4483: Subagents inappropriately inherit main agent instructions from CLAUDE.md/AGENTS.md - #3031: Model in BUILD mode does not have enough context to continue after compaction - #4102: Epic: Compaction Update (addresses context loss and rules preservation during compaction) - #5934: Session Todo-list is forgotten after compaction (related context loss issue) The core issue appears to be that auto-compaction may be incompletely preserving the subagent's system prompt and specialized instructions. Issues #4483 and #4102 directly address similar problems where context or instructions are lost after compaction. Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Dec 31, 2025):

Can u share a session this happened in?

opencode export > session.json

@rekram1-node commented on GitHub (Dec 31, 2025): Can u share a session this happened in? `opencode export > session.json`
Author
Owner

@gasatrya commented on GitHub (Dec 31, 2025):

@rekram1-node Here it is

session.json

@gasatrya commented on GitHub (Dec 31, 2025): @rekram1-node Here it is [session.json](https://github.com/user-attachments/files/24397334/session.json)
Author
Owner

@esau-morais commented on GitHub (Jan 3, 2026):

also having similar issue, but with manual /compact. is this session context limit expected? even tho it might not be the best practice having large sessions, it is quite frustrating to lose like this

@esau-morais commented on GitHub (Jan 3, 2026): also having similar issue, but with manual `/compact`. is this session context limit expected? even tho it might not be the best practice having large sessions, it is quite frustrating to lose like this
Author
Owner

@TomLucidor commented on GitHub (Jan 20, 2026):

@esau-morais there are times when even compact attempts are over the token limit, so I would not be surprised that those using truncation to hack over this limitation would have other side effects. I feel like agents needs to carry on their "identity" in working memory, while other less important long-term memory can be parked into documents.

@TomLucidor commented on GitHub (Jan 20, 2026): @esau-morais there are times when even compact attempts are over the token limit, so I would not be surprised that those using truncation to hack over this limitation would have other side effects. I feel like agents needs to carry on their "identity" in working memory, while other less important long-term memory can be parked into documents.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4035