Skip to content

[FEATURE]: Background Incremental Context Compaction for Seamless UX #16466

Closed as not planned

Description

@shaofengluo-ctrl

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

Summary

OpenCode's current context compaction feels too explicit and blocking during long sessions.

When the context window gets near full, the UI visibly enters a compaction phase and the user has to wait before continuing. This makes long coding workflows feel interrupted at the worst possible moment.

I would like to suggest a more seamless approach: background incremental compaction instead of foreground all-at-once compaction.

In contrast, the best long-session systems make context refresh feel almost invisible: usage drops smoothly, the conversation continues, and the user barely notices a memory transition happened at all.

Problem

Current behavior feels roughly like:

  • work normally
  • context becomes full
  • stop and compact visibly
  • wait until compaction finishes
  • continue

This has a few UX downsides:

  • it interrupts the flow of work
  • compaction latency is fully exposed to the user
  • the user cannot immediately continue the next step
  • long sessions feel less responsive than they should

From a user perspective, the problem is not only that compaction may be slow. The bigger issue is that compaction is too visible and too foregrounded.

Proposed Direction

Instead of waiting until compaction is urgently needed, OpenCode could:

  • maintain a rolling task summary in the background
  • compact only newly accumulated turns since the last checkpoint
  • separate raw tool output from the main prompt when possible
  • use soft thresholds to start summarization early
  • keep blocking compaction only as a fallback path

Desired Behavior

The ideal UX would be:

  • compaction is mostly invisible
  • the user can keep working while memory is being refreshed
  • long sessions feel continuous rather than periodically paused
  • the system behaves more like ongoing memory maintenance than emergency cleanup

Suggested High-Level Design

Two-layer memory:

  • active working context for the latest turns and immediate tool state
  • structured task memory for goal, confirmed findings, evidence, open questions, and next steps

Incremental policy:

  • summarize every N turns or at soft usage thresholds
  • compact only the delta since the previous summary
  • swap in the new summary once ready

Storage policy:

  • keep large raw tool outputs outside the main prompt when possible
  • keep only compact references and promoted conclusions in working memory

Why This Matters

The best compaction UX is the one the user barely notices.

For a coding agent, visible "please wait while compacting" moments feel much worse than background memory maintenance, especially during long debugging or implementation sessions.

If Helpful

If this direction sounds useful, I can also provide a more technical RFC / implementation sketch with:

  • memory schema
  • threshold policy
  • background scheduling model
  • fallback behavior
  • success metrics

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Mar 7, 2026
  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 7, 2026
  3. github-actions commented on Mar 7, 2026

    @github-actions
    Contributor

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

  4. lucad87 commented on Mar 14, 2026

    @lucad87

    I agree this feature should be awesome!

  5. assigned and unassigned on Apr 26, 2026
  6. removed
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  7. utapyngo commented on May 10, 2026

    @utapyngo

    There is already an implementation but it has not been updated for a long time: #15130

  8. github-actions commented on Jul 10, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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