Skip to content

[FEATURE]: Async background compaction — don't block chat input #27358

Closed

Description

@4nur44g

Problem

When auto-compaction fires (compaction.auto: true), it runs synchronously in the session loop, freezing the prompt input until it completes. On slow models or large contexts, this can lock the user out for minutes. The TUI becomes unresponsive and you can't even type.

Proposed behavior

  • Compaction runs as a background job — user keeps chatting uninterrupted
  • New messages sent during compaction get appended to the uncompacted history
  • Once compaction finishes, the old history gets replaced by the compacted summary
  • A toast or indicator shows "Compacting…" while it runs
  • On completion, emit session.compacted and swap in the compacted context

Existing foundation

SDK already defines CompactionPart and EventSessionCompacted — the event plumbing is there, only the execution path needs to become non-blocking.

Config

Could expose a toggle (default false for safety):

"compaction": {
  "auto": true,
  "background": true
}

Activity

  1. github-actions commented on May 13, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • The feature request template was not used — the required verification checkbox (confirming the feature hasn't been suggested before) is missing.
    • The title should follow the format [FEATURE]: <title> (missing the colon after [FEATURE]).

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


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

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. changed the title [-][FEATURE] Async background compaction — don't block chat input[/-] [+][FEATURE]: Async background compaction — don't block chat input[/+] on May 13, 2026
  3. github-actions commented on May 13, 2026

    @github-actions
    Contributor

    Thanks for updating the issue title and adding detailed content! However, there is still one required item missing from the Feature Request template:

    • Verification checkbox: The feature request template requires a checkbox confirming you have searched existing issues to ensure this hasn't been suggested before (e.g., - [x] I have searched existing issues and this has not been requested yet). Please add this to your issue.

    Please edit the issue to include this checkbox. Note that there are also potentially related issues (#16466, #13033) that you may want to review to confirm this is distinct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs:complianceThis means the issue will auto-close after 2 hours.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions