Skip to content

Manual context compaction skips a single long turn #3542

Closed

Description

@Astro-Han

What happened

Manual Context Compaction does nothing when the completed Session history contains only one user Turn, even if that Turn contains a long Agent Loop with many completed assistant and tool steps.

The result is unchanged with reason insufficient_turns. The summarizer is never called.

A Turn can legitimately contain many Agent Loop steps, so Turn count should not decide whether its completed history can be compacted.

How to reproduce

  1. Start a Session with one user Turn.
  2. Let the Agent Loop produce a substantial number of completed assistant and tool steps.
  3. Wait for the Turn to finish.
  4. Run manual Context Compaction.
  5. Observe insufficient_turns and no new checkpoint.

With the same RuntimeEvents, minRecentTurns: 1 reproduces the skip. Setting it to 0 selects a replaceable prefix and produces a checkpoint draft.

Environment

  • Maka commit: f19eede03a829c226be39f001b2684860a3aa1d5
  • OS: macOS
  • Surface: Desktop / Runtime Host

Logs, screenshots, or additional context

The guard is in packages/runtime/src/history-compact.ts: histories with at most one Turn are rejected unless minRecentTurns === 0.

Manual compaction defaults this value to 1. Oversized-turn recovery already overrides it to 0.

The fix should also remove the duplicated manual policy construction. Manual, pre-turn, mid-turn, and overflow compaction should use the same checkpoint path, with trigger-specific retention expressed as explicit input. The change should cut over atomically and remove the superseded production path in the same PR.

The separate, default-off semanticCompact experiment is out of scope and is being discussed separately in #3541.

Drafted with Codex. I reproduced the behavior and reviewed the report.

Activity

  1. Astro-Han commented on Aug 23, 2026

    @Astro-Han
    ContributorAuthor

    I’d like to take this one. I reproduced the single-Turn skip locally and confirmed that the same events become compactable when the manual path stops retaining the whole Turn.

    I’ll use this fix to consolidate the standard manual, pre-turn, mid-turn, and overflow cases onto one checkpoint path, with the old production path removed in the same PR. I’ll keep semanticCompact out of this change while its future is discussed separately.

    I’m using Codex for the implementation and will review the final diff and test evidence myself.

  2. self-assigned this
    on Aug 23, 2026
  3. added 8 commits that reference this issue on Aug 23, 2026
    9a6f7d4
    2acb6b4
    a388fb8
    02971c5
    c0c59d0
    dca3934
    b7730fe
    2d1ecec
  4. added a commit that references this issue on Aug 23, 2026
    4852d49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions