Skip to content

/compact on the main session aborts running subagents #307

Open

Description

@GDWhisper

What happened?

Sending /compact in the main session while a subagent is still working aborts the subagent instead of only compacting the main context.

Observed order in the session:

  1. ✗ subagent review → Subagent was aborted · 可回复「重试」让模型换一种方式,或补充说明预期结果
  2. Error: The operation was aborted.
  3. Compaction · Compacted from 225,250 tokens

The child session is torn down first, and compaction only finishes afterwards. The subagent's partial work and its final report are lost, so the task had to be re-dispatched from scratch.

Steps to reproduce

  1. Ask the main agent to do work that spawns a subagent (e.g. a long review task) and wait until the subagent is actively running.
  2. While it is still running, send /compact in the main session.
  3. The subagent is aborted immediately with Error: The operation was aborted., then compaction runs.

Expected behavior

/compact should only rewrite the main session's context. A running subagent lives in its own child session and should keep running unaffected — or at least be cancelled explicitly, not silently aborted as a side effect of compacting the parent.

Version

0.1.6 (Windows 11, 10.0.26300)

Activity

  1. changed the title [-]D:/Program Files/Git/compact on the main session aborts running subagents[/-] [+]`/compact` on the main session aborts running subagents[/+] on Oct 26, 2026
  2. li-xiu-qi commented on Oct 27, 2026

    @li-xiu-qi
    Collaborator

    I’ve picked this up and opened PR #313: #313

    The fix stops manual compaction from tearing down a foreground subagent. Compaction now cancels the parent run with an explicit CompactionAbortError, and the subagent tool ignores only that reason; user cancellation, shutdown, and timeout still stop the child. The regression test failed before the change and passes now, and CI is green.

  3. self-assigned this
    on Oct 27, 2026
  4. added a commit that references this issue on Oct 27, 2026
    6e3227e
  5. li-xiu-qi commented on Oct 27, 2026

    @li-xiu-qi
    Collaborator

    Update on #313: the approach is now the unified non-aborting one. Manual compaction no longer aborts the current run; it waits for the active run to settle and then compacts, matching automatic compaction. A foreground subagent therefore finishes and its result is compacted. CI is green and the PR is ready for review.

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