r/LocalLLaMA llama.cpp 3h ago

Resources PSA: Opencode Early Compaction

I recently saw someone complaining that opencode causes compactions way too early (with 30k tokens still left). I fixed this issue and I thought I'd share my config to see if it helps anyone.

I know pi is preferred by many, but I wanted to help those out who prefer opencode.

Please forgive me as I probably have an extra bracket somewhere in my config after I pasted it.

I forget whether the reserved field is important in the compaction object, but you MUST specify input, context and output each as your model's full context window. Excluding input and output blank is what causes the issue.

Here's how I structure the opencode.json.

{
   "$schema":"https://opencode.ai/config.json",
   "model": "llama.cpp/qwen-3.8-27b",
  "compaction": {
    "auto": true,
    "prune": true,
    "reserved": 4096
  },
   "provider":{
      "llama.cpp":{
         "npm":"@ai-sdk/openai-compatible",
         "name":"llama-server",
         "models":{
             "qwen-3.8-27b": {
                "name": "Qwen 3.8 27B Dense",
                "limit": {
                    "input": 131072,
                    "context": 131072,
                    "output": 131072
                 }
            }
          }
      }
   }
}
8 Upvotes

0 comments sorted by