Ministral 3 support: error "Only user, assistant and tool roles are supported, got system"
Description
I wish to use opencode with Ministral 3 14B which was recently released. However, opencode raises an error immediately:
Only user, assistant and tool roles are supported, got system
To understand it better, here is first my setup, and how to reproduce the error, which I expect will occur even for the Ministral 3 3B, as we will see later.
I run the server using weights downloaded from unsloth:
huggingface-cli download unsloth/Ministral-3-14B-Reasoning-2512-GGUF Ministral-3-14B-Reasoning-2512-Q5_K_M.gguf
docker run --gpus all -v /data/ml/models/gguf:/models -p 11432:8080 ghcr.io/ggml-org/llama.cpp:full-cuda -s --host 0.0.0.0 -m "/models/Ministral-3-14B-Reasoning-2512-Q5_K_M.gguf" --ctx-size 0 -ub 2048 -b 2048 --n-gpu-layers 99 -fa on -c 65536
I then run opencode with the following configuration, as per the documentation:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"llama.cpp": {
"npm": "@ai-sdk/openai-compatible",
"name": "llama-server (local)",
"options": {
"baseURL": "http://127.0.0.1:11432/v1"
},
"models": {
"ministral-3-14b": {
"name": "Ministral 3 14B (local)"
}
}
}
}
}
Then I request anything, and get the error pasted at the top.
The reason I get this error is that llama.cpp relies on the Jinja template inset in the GGUF, which it copied from the original Ministral repository. It loops over loop_messages, expecting not to have system messages. It only expects a system message on the first message.
However, that clearly is not the case with opencode, which can seemingly have up to 3 system messages: https://github.com/sst/opencode/blob/ee4437ff32fc2acbd2220060fc980a096730bcee/packages/opencode/src/session/prompt.ts#L651-L660
For opencode to support Ministral, it needs a single system prompt with the current Jinja template, concatenating them.
OpenCode version
1.0.129
Steps to reproduce
I run the server using weights downloaded from unsloth:
huggingface-cli download unsloth/Ministral-3-14B-Reasoning-2512-GGUF Ministral-3-14B-Reasoning-2512-Q5_K_M.gguf
docker run --gpus all -v /data/ml/models/gguf:/models -p 11432:8080 ghcr.io/ggml-org/llama.cpp:full-cuda -s --host 0.0.0.0 -m "/models/Ministral-3-14B-Reasoning-2512-Q5_K_M.gguf" --ctx-size 0 -ub 2048 -b 2048 --n-gpu-layers 99 -fa on -c 65536
I then run opencode with the following configuration, as per the documentation:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"llama.cpp": {
"npm": "@ai-sdk/openai-compatible",
"name": "llama-server (local)",
"options": {
"baseURL": "http://127.0.0.1:11432/v1"
},
"models": {
"ministral-3-14b": {
"name": "Ministral 3 14B (local)"
}
}
}
}
}
Then I enter a message, and I see the error:
Only user, assistant and tool roles are supported, got system
Screenshot and/or share link
Operating System
Ubuntu 24.04.2 LTS
Terminal
Alacritty