Skip to content

Compaction keeps a whole long exchange verbatim when the last user message is far behind the cut #54648

Closed as duplicate

Description

@superbiche

Description

Summary compaction keeps the newest keep tokens (default 15,000) verbatim beside the summary. But recentStart in packages/core/src/session/compaction.ts then walks back to the newest user message before that cut, however far back it is. After one user message followed by a long run of tool calls, the whole run is kept.

Seen on a worker session (one message, then ~50 tool turns): the compaction kept 434k characters of recent (~108k tokens) and summarized 61k; the context was still at 57% of the ceiling afterwards. The next compaction, 16 minutes later, had no user message since the checkpoint, so the last branch of recentStart kept everything and the summarizer re-read the previous checkpoint with those 434k characters inside (449k-character input). Over 9 consecutive compactions on two such sessions, 7 kept 1–3× the allowance. Headless or delegated runs that work for a long time on one message hit this every time.

Plugins

A compaction plugin that supplies the summary text. It does not touch recent; core picks the kept part before hooks run.

OpenCode version

2.0.24. recentStart is the same on dev (707de58) and v2.0.26.

Steps to reproduce

  1. Send one message that makes the agent run many tool calls (~40k tokens of tool output).
  2. Let auto compaction trigger, or run /compact.
  3. In the stored compaction row, recent starts at that user message and far exceeds compaction.keep.tokens.

Screenshot and/or share link

No response

Operating System

Fedora 44

Terminal

Ghostty


@superbiche · user · drafted with Claude Fable 5.1, reviewed before posting; the voice and decisions are mine.

Activity

  1. opencode-agent commented on Oct 11, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report and the measurements. I think this is a duplicate of #43250. It describes the same thing: the walk-back from the keep.tokens cut to the newest user message has no limit, so a single prompt followed by a long tool run is kept verbatim in recent. That issue already has measured cases from 2.0.15, 2.0.18 and 2.0.24 in one-prompt autonomous sessions.

    Possible duplicates and related issues, ordered by likelihood:

    Your PR #54649 takes a different approach to the same bug. It would help to link it to #43250 as well, so maintainers can compare it with #53233. The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.

  2. opencode-agent commented on Oct 12, 2026

    @opencode-agent
    Contributor

    We haven't heard back, so I'm closing this as a duplicate of #43250. That issue covers the same problem: the walk-back to the newest user message has no limit, so a long tool run after one prompt is kept whole in recent, far past compaction.keep.tokens. Please follow #43250 for updates. PR #53233 targets it, and it would help to link your PR #54649 there too so maintainers can compare the two fixes. If your case turns out to be different, reply here and we can reopen. Thanks for the detailed measurements!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions