Compaction Failing to Run on Time #3932

Open
opened 2026-02-16 17:41:59 -05:00 by yindo · 14 comments
Owner

Originally created by @DamianB-BitFlipper on GitHub (Dec 28, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

I have noticed when using opencode recently with Opus 4.5 (unsure if its the model's fault), compaction fails to run on time and the context balloons too big before compaction can reduce it. See the image

Image

If I try to run /compact after this, the same error repeats. If I write a text prompt, it also fails with the same errors. This forces me to start a new session.

OpenCode version

1.0.203

Steps to reproduce

Just code with Opus long enough until it comes time to compact.

Screenshot and/or share link

Session here: session-ses_49bf.md

Operating System

macOs 15.6.1

Terminal

Ghostty

Originally created by @DamianB-BitFlipper on GitHub (Dec 28, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description I have noticed when using opencode recently with Opus 4.5 (unsure if its the model's fault), compaction fails to run on time and the context balloons too big before compaction can reduce it. See the image <img width="718" height="79" alt="Image" src="https://github.com/user-attachments/assets/43dd20f6-2004-4ef8-beef-8ea3de21390e" /> If I try to run `/compact` after this, the same error repeats. If I write a text prompt, it also fails with the same errors. This forces me to start a new session. ### OpenCode version 1.0.203 ### Steps to reproduce Just code with Opus long enough until it comes time to compact. ### Screenshot and/or share link Session here: [session-ses_49bf.md](https://github.com/user-attachments/files/24358956/session-ses_49bf.md) ### Operating System macOs 15.6.1 ### Terminal Ghostty
yindo added the bug label 2026-02-16 17:41:59 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 28, 2025):

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

  • #6068: [BUG]: Auto compaction not triggering reliably with Anthropic models - Same issue with Opus 4.5 context balloons and compaction failures
  • #5934: Session Todo-list is forgotten after compaction - Related compaction problem with Opus 4.5 127k context
  • #5478: prompt is too long when replacing in a file - Similar 'prompt is too long' errors when context approaches limits
  • #4845: prompt is too long unrecoverable - Duplicate of same 'prompt too long' error with Opus 4.5

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Dec 28, 2025): This issue might be a duplicate of existing issues. Please check: - #6068: [BUG]: Auto compaction not triggering reliably with Anthropic models - Same issue with Opus 4.5 context balloons and compaction failures - #5934: Session Todo-list is forgotten after compaction - Related compaction problem with Opus 4.5 127k context - #5478: prompt is too long when replacing in a file - Similar 'prompt is too long' errors when context approaches limits - #4845: prompt is too long unrecoverable - Duplicate of same 'prompt too long' error with Opus 4.5 Feel free to ignore if none of these address your specific case.
Author
Owner

@DamianB-BitFlipper commented on GitHub (Dec 28, 2025):

#6068 seems related.

@DamianB-BitFlipper commented on GitHub (Dec 28, 2025): #6068 seems related.
Author
Owner

@Fryuni commented on GitHub (Feb 9, 2026):

When configuring skills and/or MCPs this bug becomes more prominent. It seems the auto-compaction logic is not taking into account the tokens used to send the available tools.

I currently have to keep an eye on all my running sessions to manually type /compact followed by Continue what you were doing (which can be queued without waiting for compaction to end).

@Fryuni commented on GitHub (Feb 9, 2026): When configuring skills and/or MCPs this bug becomes more prominent. It seems the auto-compaction logic is not taking into account the tokens used to send the available tools. I currently have to keep an eye on all my running sessions to manually type `/compact` followed by `Continue what you were doing` (which can be queued without waiting for compaction to end).
Author
Owner

@R44VC0RP commented on GitHub (Feb 9, 2026):

@Fryuni what version & model are you using? Opus I assume?

@R44VC0RP commented on GitHub (Feb 9, 2026): @Fryuni what version & model are you using? Opus I assume?
Author
Owner

@DamianB-BitFlipper commented on GitHub (Feb 9, 2026):

Yup. Running in to this issue recently. On Opus 4.6. opencode 1.1.53

@DamianB-BitFlipper commented on GitHub (Feb 9, 2026): Yup. Running in to this issue recently. On Opus 4.6. opencode 1.1.53
Author
Owner

@rekram1-node commented on GitHub (Feb 9, 2026):

yeah ill fix this

@rekram1-node commented on GitHub (Feb 9, 2026): yeah ill fix this
Author
Owner

@Fryuni commented on GitHub (Feb 10, 2026):

Same as Damian. Opus 4.6 using version 1.1.53

I'm tested with providers Antigravity (through the auth plugin), Vertex and OpenRouter in case it was some rule that differs per provider. Happens with all of them.

@Fryuni commented on GitHub (Feb 10, 2026): Same as Damian. Opus 4.6 using version 1.1.53 I'm tested with providers Antigravity (through the auth plugin), Vertex and OpenRouter in case it was some rule that differs per provider. Happens with all of them.
Author
Owner

@DamianB-BitFlipper commented on GitHub (Feb 11, 2026):

I don't mean to be a bother, but this issue persists on 1.1.59 and significantly impacts usability. When I'm on a deep run with Opus and encounter this error, I have to go back to an earlier point in the chat and manually compact from there, losing all the valuable context accumulated between that point and the present.

@DamianB-BitFlipper commented on GitHub (Feb 11, 2026): I don't mean to be a bother, but this issue persists on 1.1.59 and significantly impacts usability. When I'm on a deep run with Opus and encounter this error, I have to go back to an earlier point in the chat and manually compact from there, losing all the valuable context accumulated between that point and the present.
Author
Owner

@rekram1-node commented on GitHub (Feb 11, 2026):

Hmm im surprised u still hit it reliably. Im making it impossible to break session but can u send me a session by chance?

I've never replicated this bug once without intentionally blowing up context by making a bunch of super long prompts and disabling auto compact

@rekram1-node commented on GitHub (Feb 11, 2026): Hmm im surprised u still hit it reliably. Im making it impossible to break session but can u send me a session by chance? I've never replicated this bug once without intentionally blowing up context by making a bunch of super long prompts and disabling auto compact
Author
Owner

@DamianB-BitFlipper commented on GitHub (Feb 11, 2026):

Is there a way I can share you the session, but not publicly on GH here?

@DamianB-BitFlipper commented on GitHub (Feb 11, 2026): Is there a way I can share you the session, but not publicly on GH here?
Author
Owner

@rekram1-node commented on GitHub (Feb 11, 2026):

@DamianB-BitFlipper can u dm me on discord? Or email me: aiden@anoma.ly

to share a session do this:
opencode export > session.json (run this command in ur terminal) and then send me session.json

This will give me a raw json export of it that I can analyze

@rekram1-node commented on GitHub (Feb 11, 2026): @DamianB-BitFlipper can u dm me on discord? Or email me: aiden@anoma.ly to share a session do this: `opencode export > session.json` (run this command in ur terminal) and then send me session.json This will give me a raw json export of it that I can analyze
Author
Owner

@Fryuni commented on GitHub (Feb 11, 2026):

The reason I think it is a problem with the taking tools into account is because the Context on the sidebar says 154k tokens, but the request fails saying that 204k tokens is above the limit of 200k (which it clearly is).

When invoking /compact, the request is sent without the description of all the tools, just with the instruction to compact the context, so that request has still less than 160k tokens and works.

@Fryuni commented on GitHub (Feb 11, 2026): The reason I think it is a problem with the taking tools into account is because the Context on the sidebar says 154k tokens, but the request fails saying that 204k tokens is above the limit of 200k (which it clearly is). When invoking `/compact`, the request is sent without the description of all the tools, just with the instruction to compact the context, so that request has still less than 160k tokens and works.
Author
Owner

@DamianB-BitFlipper commented on GitHub (Feb 11, 2026):

The reason I think it is a problem with the taking tools into account is because the Context on the sidebar says 154k tokens, but the request fails saying that 204k tokens is above the limit of 200k (which it clearly is).

This is my observed behavior. I'm in contact with @rekram1-node

@DamianB-BitFlipper commented on GitHub (Feb 11, 2026): > The reason I think it is a problem with the taking tools into account is because the Context on the sidebar says 154k tokens, but the request fails saying that 204k tokens is above the limit of 200k (which it clearly is). This is my observed behavior. I'm in contact with @rekram1-node
Author
Owner

@rekram1-node commented on GitHub (Feb 11, 2026):

I stg will kill this bug this week I know how annoying it's been for users

@rekram1-node commented on GitHub (Feb 11, 2026): I stg will kill this bug this week I know how annoying it's been for users
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3932