Forces small_model to track the active provider's main model — but only for local Ollama.
opencode's top-level small_model setting is a global string and cannot be scoped per-provider through config. This plugin hooks experimental.provider.small_model (the same hook GitHub Copilot uses internally) to inject the correct model when the active provider is ollama. For every other provider, the plugin is a no-op and opencode's normal small-model selection (cfg.small_model → auto-pick → fall back to main) takes over.
Title generation and other auxiliary prompts routed to the configured small_model should run locally on Ollama when Ollama is the active provider — not on a remote model that costs tokens per session. By forcing small_model = main for the Ollama provider, every auxiliary prompt goes through Ollama end-to-end.
Drop the plugin file into your opencode config directory:
# Unix / macOS
cp ollama-small-model.ts ~/.config/opencode/plugins/
# Windows (PowerShell)
Copy-Item ollama-small-model.ts "$env:USERPROFILE\.config\opencode\plugins\"opencode loads ~/.config/opencode/plugins/*.ts automatically — no rebuild, no restart of any service. The plugin takes effect on the next session.
"experimental.provider.small_model": async (incoming, output) => {
if (incoming.provider.id !== "ollama") return
const models = incoming.provider.models as Record<string, unknown> | undefined
if (!models) return
const candidate =
models["qwen3.5:9b"] ??
Object.values(models).find((m) => {
const id = (m as any)?.api?.id ?? (m as any)?.id
return typeof id === "string"
})
if (candidate) output.model = candidate
}- The hook fires whenever opencode resolves
small_modelfor a provider. - If the provider is not
ollama, return immediately — opencode's default behaviour applies. - For
ollama, look upqwen3.5:9bin the already-registeredprovider.modelsmap. If absent (defensive — the provider only shipsqwen3.5:9btoday, but the fallback keeps title generation working if the model id changes), fall back to whichever model the provider exposes.
The result is written to output.model. Title generation then runs through Ollama.
- opencode with the Ollama provider configured.
@opencode-ai/plugintype definitions (declared as a dev dependency inpackage.json; opencode provides these at runtime — no install step required).
MIT