opencode-ollama-toolcall-proxy
v0.2.8
Published
OpenCode plugin that converts raw tool-call markup from local Ollama models into standard OpenAI tool_calls, plus line-ending normalization for file edits.
Maintainers
Readme
OpenCode Ollama Tool-Call Proxy Plugin
An OpenCode plugin that does two things:
- Tool-call conversion: intercepts chat-completion responses from a local Ollama server and rewrites raw tool-call markup into standard OpenAI
tool_callschunks. This lets models that do not expose native Ollama tool support still work as agentic coding models inside OpenCode. - Line-ending normalization: normalizes LF/CRLF line endings on
write,edit, andmultiedittool arguments, and on files after edits, using.editorconfigor theOPENCODE_LINE_ENDINGSenvironment variable. Platform default: CRLF on Windows, LF on Linux/macOS.
Supported model families
| Family | Example Ollama tags | Raw markup handled |
|--------|---------------------|--------------------|
| Qwen 2.5 / Qwen 2.5-Coder | qwen2.5-coder, qwen2.5 | <tools>, <tool_call>, raw JSON object/array |
| Qwen 3.5 / Qwen 3-Coder | qwen3.5, qwen3-coder | <tool_call>{...}</tool_call> and <function=...><parameter=...> XML |
| Ornith 1.0 | ornith-9b, ornith-35b | same as Qwen 3.5 (routed to Qwen converter) |
| Gemma 4 | gemma4 | <|tool_call>call:name{...}<tool_call|>, <start_function_call>...<end_function_call> |
| Mistral / Ministral | mistral, mistral-nemo, ministral, ministral-3 | [TOOL_CALLS] JSON array and <name>[ARGS]{...} |
| Llama 3.x / OpenCoder | llama3.1, llama3.2, llama3.3, opencoder | raw JSON object/array, <|python_tag>...<|eom_id|> |
| Phi-4 / Phi-4 Tools | phi4-mini, phi4-tools | {"name":..., "parameters":...}, functools[...] |
| DeepSeek R1 / V3 | deepseek-r1, deepseek-v3 | <|tool▁call▁begin|> tags, fenced JSON, raw JSON, strips <think> |
| Yi-Coder | yi-coder | raw JSON / JSON array, code fences |
| GLM-4 / ChatGLM | glm4, chatglm3 | [TOOL_REQUEST] {...} [END_TOOL_REQUEST], legacy <tool_call> XML |
| Laguna XS 2.1 | laguna-xs-2.1 | [tool=name<Prop ... />], [tool=name<arg_key>k</arg_key><arg_value>v</arg_value>] |
Installation
From npm (recommended)
npm install -g opencode-ollama-toolcall-proxyThen add the package name to your OpenCode config:
{
"plugin": ["opencode-ollama-toolcall-proxy"]
}Restart OpenCode. The plugin is loaded automatically.
From a local checkout
git clone https://github.com/YOUR_USER/opencode-ollama-toolcall-proxy.git
npm install
npm run buildReference the built entry point with an absolute file:// URL:
{
"plugin": ["file:///C:/absolute/path/to/opencode-ollama-toolcall-proxy/dist/index.js"]
}Usage
- Make sure Ollama is running.
- Configure your model in
~/.config/opencode/opencode.jsonwith"tools": true:
{
"provider": {
"ollama": {
"npm": "@ai-sdk/openai-compatible",
"options": { "baseURL": "http://localhost:11434/v1" },
"models": {
"qwen2.5-coder:14b": {
"name": "Qwen2.5 Coder 14B",
"tools": true,
"thinking": false
}
}
}
}
}- Start OpenCode. When the model emits raw tool-call text, the plugin converts it to proper
tool_callsbefore the AI SDK sees the response.
Line-ending configuration
The plugin normalizes line endings on file writes/edits in this priority order:
OPENCODE_LINE_ENDINGSenvironment variable (lforcrlf).editorconfigend_of_linesetting (walks up the directory tree)- Platform default:
crlfon Windows,lfon Linux/macOS
Example .editorconfig:
root = true
[*]
end_of_line = crlf
[*.sh]
end_of_line = lfDevelopment
# type check
npm run typecheck
# run tests
npm test
# build a single ESM bundle for publishing
npm run buildPublishing
- Pick a unique npm package name and update
nameinpackage.json. - Log in to npm:
npm login. - Publish:
npm publish.
The prepublishOnly script automatically builds dist/index.js before the package is uploaded.
License
MIT
