Repository navigation
Description
Feature hasn't been suggested before.
- I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Describe the enhancement you want to request
Disclaimer
I am a user of Opencode and do not have a background in TypeScript or the project's internal codebase. I am proposing this as a functional enhancement rather than a technical implementation plan.
1. The Problem
Currently, Opencode manages long conversations using automatic cleanup (pruning and compaction). While this is helpful for staying within token limits, it is a "system-level" decision that doesn't always align with the actual progress of the task.
For example, the system might automatically delete an important piece of code I read earlier that the agent still needs, or it might keep thousands of tokens of useless error logs that have already been resolved, simply because they are "recent."
2. The Proposed Idea: Agent-driven Context Management
I suggest giving the AI agent the ability to actively manage its own memory using a block-based system:
- Visible Block IDs: Every significant part of the conversation (a user message, a large tool output, a reasoning block) should be assigned a unique ID that the agent can see.
- Agent Control: Allow the agent to issue commands to manage these blocks. For instance:
- Discard: The agent can decide that a specific block (like a long, failed build log) is no longer useful and should be removed from its context.
- Summarize: The agent can choose to replace a massive block of data with a short summary it generates itself.
- Pin: The agent can mark a specific block as "critical" so that the automatic cleanup system never deletes it.
3. Integration with Session Reversion (Rollback)
Opencode already has a powerful "Revert" feature. It is critical that this new memory management system is integrated with it:
- Consistent Rollback: If a user reverts the session to a previous message, any "Discard" or "Summarize" actions taken by the agent after that point should also be automatically undone.
- Memory Sync: The agent's memory (the state of which blocks are hidden or summarized) must stay perfectly in sync with the conversation history. If we go back in time, the agent should "regain" the full context that was available at that moment.
4. Benefits
- Smarter Context: The agent knows better than the system which information is truly "finished" and which is "ongoing."
- Efficiency: By proactively cleaning up resolved issues, the agent can keep the conversation focused and high-quality for much longer.
- Reliability: Ensuring that memory management respects rollbacks will prevent the agent from being "confused" by missing information that it previously discarded in a future that no longer exists.
Activity
github-actions commentedon Feb 7, 2026
This issue might be a duplicate of existing issues. Please check:
Your proposal for agent-driven context management with block IDs, discard, summarize, and pin operations builds upon these related feature requests. Feel free to ignore if your specific case requires additional functionality beyond these existing proposals.
github-actions commentedon Apr 9, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.