You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Compaction keeps a whole long exchange verbatim when the last user message is far behind the cut #54648
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
Send one message that makes the agent run many tool calls (~40k tokens of tool output).
Let auto compaction trigger, or run /compact.
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.
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.
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!
Activity
opencode-agent commentedon Oct 11, 2026
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.tokenscut to the newest user message has no limit, so a single prompt followed by a long tool run is kept verbatim inrecent. 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:
keep.tokensnot honoured because of the unbounded walk-back to the last user message in agent-driven sessionsrecent, which can make the context bigger than before compaction #51818: a related wayrecentgrows larger than intended (reasoning text kept inrecent)opencode runsessions, so long headless runs compact every ~10 minutes #47485: related symptom of long headless single-turn runs compacting again and againYour 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.
opencode-agent commentedon Oct 12, 2026
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 pastcompaction.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!