r/opencode • • 12d ago

Trying to improve OpenCode's efficiency

I've been testing OpenCode and Pi with locally hosted qwen3.8-27b and I'm looking for advice on improving OpenCode's efficiency.

I prefer OpenCode, particularly its interface and ecosystem, and I'd really like to keep using it, but in my testing Pi has been noticeably more efficient at getting coding tasks done.

My setup:

  • Model: Qwen3.8-27B (Q6_K_XL)
  • Inference: llama.cpp
  • Hardware: RTX 4080 SUPER + RTX 4070 Ti SUPER (32GB combined)
  • Tasks: Real coding tasks in repos including multi-file changes, tool use, and test-driven iteration

The main issue isn't raw inference speed. It's how efficiently the agent uses its tokens and tools to complete a task.

Here's one example... I've been testing both harnesses using the same coding task in a TypeScript repo. Using OpenCode, the model spends a lot of time reasoning about the implementation ("but wait..."), revisiting decisions ("actually..."), and sometimes going through context compaction without making corresponding progress. With Pi, the same underlying model has generally been more willing to move from analysis into tool calls and implementation.

In both cases the model can do the work. The question I'm running into is why the harness seems to make such a difference in how efficiently it gets there.

If you've optimized OpenCode for local models (particularly qwen3.8-27b, which is known to overthink):

  1. Have you found prompt or agent configurations that reduce unnecessary reasoning and encourage more direct tool use?
  2. Have you simplified OpenCode's tool definitions or system prompt to improve local-model performance?
  3. Have you found any compaction or context management behaviors that could produce more over-thinking than with other harnesses?
  4. Have you found any other settings or modifications worth testing to get OpenCode invoke the model more efficiently from an over-thinking perspective?

I'm not looking to argue that one harness is better than the other. I want to keep using OpenCode but improve it's use of this model.

I appreciate your thoughts!

--

Edit for grammar.

19 Upvotes

17 comments sorted by

8

u/DagothUrLovesGroza 12d ago

I thought about doing something similar, but honestly it is probably a waste of time. OC, at its core, is built for big cloud models. As time passes, more and more features will be tuned purely for those big cloud models with huge context windows.

As a rule of thumb, with locally hosted models you should always use Pi, purely because it is so minimalistic.

4

u/previaegg 12d ago edited 12d ago

Yeah, I get that Pi's minimalism is a big part of why it works so well with local models, but that's actually what I'm wondering about. What is it about how Pi interacts with the model that differs from OC that allows for it to be as efficient as it is? I'd love to try to mimic that in OC so that I can retain the UI and other features I prefer.

I'm interested in how much of the difference comes from things we can configure or simplify (system prompts, tool definitions, context management, etc.) versus fundamental architectural differences that can't easily be worked around.

3

u/CrypticViper_ 12d ago

I’m sure your intent was good but read the last section of the post, OP knows

4

u/learning-to-programm 12d ago

"I prefer OpenCode to Pi due to its ecosystem"

That's nota sentence I thought I'd hear. Pi's ecosystem is much more robust and creative, imo. And I think that's by design, as it is supposed to be tweaked to each person's liking. Take a look at the pi packages page, the pi agent subreddit, or for anything you find lacking just google Pi [thing].

But anyway, I and other people have also seen the same thing - that smaller models tend to run better on Pi (and allegedly Hermes too) than on OpenCode. Some say it's due to lack of bloat.

And coincidentally, I also got your exact symptoms: LLM thinking nonstop, reading the sane files over and over, and compacting before it's done barely any work. Mostly with a 33B model (Agnes 2.5). In Pi the same model performed much better and was actually half competent.

Now, I haven't tried it, but maybe you could create a custom agent with a leaner system prompt, and use that rather than the default @general agent from OpenCode? Maybe use very specific prompts to limit the scope of the LLM's work, and thus have do more and think less?

1

u/previaegg 12d ago

True. I guess I prefer OpenCode's UI and workflow rather than its ecosystem. I've been exploring Pi and its extensions, and for sure there is a lot there.

It's interesting that you've seen the same behavior, particularly the repeated file reads, endless reconsideration, and compaction without much progress.

I've already tried the custom agent approach (at least as best as I know how). I created an OC agent with a minimal system prompt, and another variant using Pi's coding instructions adapted to OpenCode's tools. I kept the model, reasoning settings, and coding task consistent and ran both of them. Interestingly, the Pi-instructions variant was slightly slower than the minimal OpenCode agent. Both were still at least 30% more inefficient than the Pi run. So simply adopting Pi's instructions doesn't appear to solve the problem.

I'm now more interested in the differences in tool schemas, message construction, and agent-loop behavior.

I'd really like to keep OpenCode, but at the same time I find myself wondering why I am fighting to make it as efficient as Pi when I could just use Pi...

1

u/learning-to-programm 12d ago

Uhhh, interesting. Looks like the system prompt has much less of an effect than I thought.

But I'd say, keep tinkering and trying till you've figured it out.

I'd really like to keep OpenCode, but at the same time I find myself wondering why I am fighting to make it as efficient as Pi when I could just use Pi...

I think it'd due to moments like these that our community advances who knows what might come out of this, if you keep tinkering and poking at the problem.

If you do figure it out, lmk lol. I do like OpenCode as well, and it'd be nice to know that I can use my cheap models there too.

1

u/taytay735 12d ago

I did a short search on pi previously - Opencode v2 already does some of the things that pi-durable (supposedly next gen pi) was meant to patch in pi, so i didn’t look too much into pi.

1

u/previaegg 12d ago

What were those things? Did you run any jobs in OC and Pi side by side?

1

u/taytay735 12d ago

I hadn’t tried simultaneous workloads for comparison, so it’s an entirely paper study (using AI).

I reran the analysis again and it seems pi durable offers more features.

What they share
* multi clients and multi conversations
* background compaction
* live config reload
* durable message queue on restart

What Pi Durable does better
* task state machines
* tool retries on crash
* atomic application and message state

And some other stuff that I’m not sure has a direct translatable benefit, but seems to make Pi Durable more … well, durable.

The question then is, when doing harness evaluations should we use pi durable or is it and the ecosystem not ready yet?

3

u/lincolnthalles 12d ago

First, make sure your local deployment has enough context for the job and that the harness is configured accordingly. A context under 200K is borderline useless for coding.

Inspect the whole thread history (the JSON API queries) and compare. Something could be wrong with code mode or other tool calling and may require you to adjust things in the host or in the harness.

Even OpenCode Go's DeepSeek V4.1 deployment suffers from related issues sometimes. I had a thread where OpenCode V2 filled the context very quickly by inserting a warning (regarding code mode usage) to the model at every wrong tool call it made (and all tool calls were wrong).

About a month ago, DeepSeek on Go was brain-dead for many people for weeks with a similar behavior to what you described, and it was later fixed and attributed to a deployment issue.

The system prompt does play a role in model behavior, but it's pretty minimal for OpenCode V2. Tool descriptions are bigger.

OpenCode V2 compaction is hardcoded, and the prompt is generated programmatically. The results are quite decent, so it's the last thing I would change. First, check why the context is being filled so fast: is your context too little to work with, or is the harness dumping warnings as I described?

You can override the system prompt for any other agent, so you may play with that by creating a prompt that gives the model a procedure to follow. The issue is that a decent prompt will be big, and you already have a context problem.

*** opencode.jsonc ***

{
  "agents": {
    "build": {
      "system": "{file:system-prompt.md}"
    }
  }
}

If you narrow the issue to the delay or the "but wait", I'd suggest you review the results as you tweak things. Too much hesitation is bad, but a hyper-confident model is even worse, as it will produce only slop.

1

u/previaegg 12d ago

Thank you for your thoughtful reply. I've been capturing the raw model-facing JSON requests from both OC and Pi harnesses, so I've been able to investigate some of this, and unfortunately context exhaustion is not the underlying issue. Pi is completing substantially more work within the same context budget, and the difference in behavior appears well before either harness approaches the limit.

For example, in one controlled comparison Pi started implementing at exchange 9, while OpenCode (using a minimal custom agent profile and lean system/user prompts) was still investigating after exchange 17. Both had read comparable amounts of source code. OpenCode was spending more time reconsidering its approach and investigating peripheral details rather than moving into implementation.

I agree that context management matters but mostly I'm trying to understand why the same model, given the same task and context budget, makes such different decisions about when to stop investigating and start implementing.

1

u/for4f 12d ago

yeah this matches what i've seen running local stuff through opencode too. the harness assumes a big frontier model that can juggle a ton of context and tools at once, so with a 27b it just sits there second-guessing itself lol. pi's loop is dumber in a good way, it pushes the model toward acting instead of thinking about acting. thing i'd actually check is the compaction and reasoning settings. opencode compacts and then the small model basically starts over, re-reasoning stuff it already decided. if you can raise the compaction threshold or cut the reasoning budget down it wastes way fewer tokens per task. also worth trying the same task with plan mode off if you've got it on, small models go in circles in plan-then-act loops. for local models i've mostly landed on simpler harness equals better harness. opencode's ecosystem is great when the model can keep up, but under like 30b that extra machinery works against you.

2

u/previaegg 12d ago

I really appreciate your thoughts. The distinction between OC being aimed at larger model usage and pi's loop making better use of smaller models is interesting. What I'm trying to determine is the specific differences that produce those characteristics.

I'm seeing overthinking start well before context exhaustion/compaction, so I don't think compaction is the primary cause.

I've tested reasoning settings and a minimal custom OC agent, including a version using pi's coding instructions adapted for OC. Neither has eliminated the behavior. I've also compared the model-facing requests from both harnesses. In one comparison, pi started implementing by exchange 9, while "minimal OC" was still investigating after exchange 17, despite both having read comparable amounts of source code.

I'm wondering whether there's something specific about OC's tool schemas, messages, or agent loop that's encouraging this behavior, and whether it can be changed.

1

u/for4f 11d ago

oh that's a great data point, exchange 9 vs 17 with comparable code read kills the compaction theory dead lol.

my money's on the system prompt plus tool schemas. opencode ships a pretty chunky default prompt with all the plan-verify-re-read instructions, and a 27b treats every one of those like a mandatory step instead of a suggestion. pi just hands the model the last tool result and goes ok what's next, so it acts instead of deliberating.

you're already capturing the model-facing json so the easiest check is comparing system prompt sizes between the two runs. wouldn't be surprised if OC's is like 3-4x pi's. and if you're feeling experimental, gut OC's system prompt down to something pi-sized and see if the exchange count moves. curious what you find

1

u/Agile-War-1904 12d ago

The thing that actually moved the needle for me wasn't prompt tweaking, it was tool surface area. I had two MCP servers attached and one of them exposed 200+ tools, and that schema alone was eating a huge slice of every request before I typed anything. Grouping them behind a single dispatch tool (Code Mode) cut the overhead more than any instruction change did. Worth measuring the token count of your tool block before you start optimizing prompts.

1

u/previaegg 12d ago

Thanks for the suggestion. I'll have a look at tool exposure. For this task I believe there were only 4/5 tools exposed and that both harnesses had basically equivalent tools.

I can see how additional tools would impact context usage, but in this scenario I am not exhausting context. Do you think additional tools might somehow contribute to OC's inefficiency moving from thinking to acting?

1

u/BABAIIYAGA 6d ago

same model behaving that differently points to d harness more than d model.. I would compare tool calls nd system prompts first hindsight also supports both OpenCode and PI if u want to test whether retaining repo decisions cuts down on repeated reasoning.. just would not expect memory alone to fix overthinking...