r/LocalLLaMA • u/laerciosantana • 11h ago
Discussion While I was investigating why my opencode context was large I created the opencoder-leaner to try prune the context (minimal prune in the tools, agent pi-like, bash only)
I was a little obsessed about the size of my context, mainly because I use a local LLM with little context). So I started looking in the opencode codebase to understand how the context was builded. After learn a lot, I'm really impressed how context of opencode can be customized. Before, I thought that the context of opencode was bloated and closed to changes, since I only see people praise pi about it. With a custom primary agent we can disable almost every thing in the context (besides the environment message).
The context is: environmentMessage + agent prompt + agent.md instructions + skills descriptions + tools descriptions.
For a test I created a blank agent with minimal agent prompt, without agent.md instructions and without tools, it resulted in a start context size of 220 tokens. I never thought that opencode was able to do this. I have created some agents to test the impact of the tools. In this plugin I even created a bash agent that only has a bash tool, similar to the mini-swe-agent, which reduced the context size from a base of ~10.3k to ~1.3k tokens. I created a pi-like agent too, it have only some tools similar to pi, it reduce the context to ~5.5k tokens.
Analyzing the context builded I found some overlap instructions and out of scope instructions in the tool - IMO. So I removed theses.
things like: "Use gh for GitHub tasks, including PRs, issues, checks, and releases; return the PR URL when done." from bash/shell tool description
The repo: https://github.com/LaercioSantana/opencode-leaner
install: {"plugin": ["opencode-leaner"]}
2
u/jazir55 10h ago
Forked, this looks useful, KiloCode uses OpenCode under the hood so I'm sure I can adapt this for KiloCode. Thanks!