| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Sorry, something went wrong.
|
The following comment was made by an LLM, it may be inaccurate: I found one potentially related PR: PR #9656: feat(opencode): trigger compaction earlier and add multi-file read This PR appears to address compaction triggering behavior, which is related to the compaction threshold configuration being added in the current PR (#10123). However, it seems to focus on multi-file read functionality as well, so they may not be exact duplicates. You should review #9656 to ensure there's no overlap in the compaction logic implementation. |
Sorry, something went wrong.
|
EDITS: Correctly mentioned the issue being fixed. Reviewed the potentially related PR, this one focuses solely on customizing the early compaction threshold as per the user's need, while preventing infinite compaction loop. Meanwhile the related PR (#96956) is a hardcoded early compaction (at 90% of the context) fix along with multi-file read validation. |
Sorry, something went wrong.
|
@jeremyakers Just +1 on this PR! Custom compaction thresholds are critical for long-context models like Gemini/GPT that degrade quality at 30-50% context. The hardcoded 75% threshold causes severe performance issues in production workflows. Having per-model threshold configuration would allow power users to:
This aligns perfectly with the 'auto-archive' mode you mentioned - both give users fine-grained control over when context gets compacted. Happy to test beta implementations! |
Sorry, something went wrong.
|
@WietRob I have added a commit allowing model-specific threshold control, thank you for the suggestion! Here is a sample config. {
"$schema": "https://opencode.ai/config.json",
"compaction": {
"token_threshold": 100000,
"context_threshold": 0.30,
"models": {
"opencode/minimax-m2.1-free": {
"token_threshold": 50000,
"context_threshold": 0.10
}
}
}
}It would be great help if you could test it out as well. |
Sorry, something went wrong.
|
@saksham1341 Tested this with opencode/minimax-m2.1-free using a 5% threshold in my config. It definitely works - I pushed context to ~24% and it triggered compaction immediately (and kept compacting as I stayed over the limit). The model-specific overrides are doing their job. Thanks for adding this! |
Sorry, something went wrong.
|
Thank you for implementing this! I have tested it with opencode 1.2.10. Working config format: {
"compaction": {
"token_threshold": 60000,
"context_threshold": 0.45,
"models": {
"google/antigravity-gemini-3-flash": {
"context_threshold": 0.30
},
"google/antigravity-gemini-3-pro-high": {
"context_threshold": 0.30
}
}
}
}Note: The following keys from my previous config are not supported in this implementation:
These should be removed. The supported keys are only:
Feature request: Would it be possible to add min_messages (minimum messages between compactions) to prevent continuous compaction loops? This would be especially useful for long-running sessions. |
Sorry, something went wrong.
|
@WietRob how did you get this to work? I just updated my opencode to 1.2.12 and adjusted my opencode.json accordingly. Still, the auto compaction only kicks in at 75%. // opencode.json
{
"$schema": "https://opencode.ai/config.json",
"compaction": {
"token_threshold": 60000,
"context_threshold": 0.45
},
"mcp": {
...
}
}
|
Sorry, something went wrong.
|
nudge! |
Sorry, something went wrong.
|
@fea17e86 Sorry for the confusion! I just tested this myself and found the issue. Why it doesn't work for you: What I found when testing the PR branch:
To use these features now: git clone https://github.com/anomalyco/opencode.git
cd opencode
git fetch origin pull/10123/head:pr-10123
git checkout pr-10123
# Follow the build instructions in the repoYour config format is correct - it will work once this PR is merged and released. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
What does this PR do?
This PR Closes #10017 configurable thresholds for session compaction, allowing users to define when compaction triggers based on token count or context usage percentage via opencode.json.
It also introduces a min_messages configuration to prevent infinite compaction loops. This ensures a minimum number of message turns must pass after a summary before a new compaction is triggered, solving edge cases where context remains overflowing immediately after compaction.
How did you verify your code works?
{ "$schema": "https://opencode.ai/config.json", "compaction": { "token_threshold": 15000, "context_threshold": 0.06, "min_messages": 5 } }