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
LM Studio a local 7B model issue "Cannot truncate prompt with n_keep (15028) >= n_ctx (7424)" #11141
Increasing context size does not resolve the issue. It delays it. Eventually you have too many token to run anything. I'm having the same problem but I can't find away to adjust N_keep, so it will dump the tokens.
I'm getting a similar error Cannot truncate prompt with n_keep (11378) >= n_ctx (4096)" with qwen/qwen3.5-9b and opencode 1.2.21.
Edit: Seems like this isn't an issue with OpenCode itself, but with the configuration in LM Studio. I fixed this by setting the context length to the maximum the model supports (256k)
As I said before. Increasing the context window only delays the inevitable issue Wilson and I are having. Increasing context window and setting it to rolling window only works when using the LM UI. When using LM as a server and a deferent program as the UI, like Open Interpreter. You will get the n_keep error. Reloading the model, relaunching LM, rebooting the pc, deleting and reinstalling LM Studio. None of them work to resolve the issue. It as files all over the place that you have to track down and delete in order to fix it. But that has to be done every time you get the n_keep error. The highest context window I can run is 128k. That is about 3.5-4 hours of work.
While working with LLAMA 7B in Android Studio, I encountered persistent errors that prevented successful execution. I attempted to adjust various settings, but none of the changes resolved the issue.
The errors consistently appeared during prompt execution, regardless of configuration changes. Unfortunately, I am currently unable to reproduce the issue, but I want to document it here for visibility and potential troubleshooting.
Steps Taken
Adjusted Android Studio project settings (memory allocation, Gradle configs, etc.)
Attempted to lower the prompt size
Increased the context length
Reloaded the environment and retried execution
Observed Behavior
Activity
github-actions commentedon Jan 29, 2026
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
mgonzalezlopezudc commentedon Feb 13, 2026
Same behavior here with Qwen 0.6B running on LMstudio. However, setting in LMstudio the context for the model up to maximum, fixes the issue
KevinGimbel commentedon Feb 16, 2026
Same with
openai/gpt-oss-20b, setting context to max fixed it.Jamescd1980 commentedon Feb 28, 2026
Increasing context size does not resolve the issue. It delays it. Eventually you have too many token to run anything. I'm having the same problem but I can't find away to adjust N_keep, so it will dump the tokens.
max-arias commentedon Mar 3, 2026
Same issue with
qwen/qwen3.5-9brunning through LM Studio 0.4.6, Opencode 1.2.15elecNation commentedon Mar 4, 2026
通过LM Studio 0.4.6,OpenClaw 运行的qwen/qwen3.5-9b 有同样的问题
wilsonsilva commentedon Mar 8, 2026
I'm getting a similar error
Cannot truncate prompt with n_keep (11378) >= n_ctx (4096)"withqwen/qwen3.5-9band opencode1.2.21.Edit: Seems like this isn't an issue with OpenCode itself, but with the configuration in LM Studio. I fixed this by setting the context length to the maximum the model supports (256k)
Jamroszczyk commentedon Mar 9, 2026
Consider your available memory, however, before setting it to max. Some models explode with the max value.
Jamescd1980 commentedon Mar 9, 2026
As I said before. Increasing the context window only delays the inevitable issue Wilson and I are having. Increasing context window and setting it to rolling window only works when using the LM UI. When using LM as a server and a deferent program as the UI, like Open Interpreter. You will get the n_keep error. Reloading the model, relaunching LM, rebooting the pc, deleting and reinstalling LM Studio. None of them work to resolve the issue. It as files all over the place that you have to track down and delete in order to fix it. But that has to be done every time you get the n_keep error. The highest context window I can run is 128k. That is about 3.5-4 hours of work.
codinoob1 commentedon Mar 12, 2026
While working with LLAMA 7B in Android Studio, I encountered persistent errors that prevented successful execution. I attempted to adjust various settings, but none of the changes resolved the issue.
The errors consistently appeared during prompt execution, regardless of configuration changes. Unfortunately, I am currently unable to reproduce the issue, but I want to document it here for visibility and potential troubleshooting.
Steps Taken
Observed Behavior
Expected Behavior
Notes
github-actions commentedon May 12, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.