anomalyco / anomalyco/opencode
Qwen 3.8 renderer rejects multiple system messages with "system message must be at the beginning"
@jlongster is already working on this.
Since Aug 16, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Problem
The new qwen3.8:27b model fails when the OpenAI-compatible /v1/chat/completions endpoint receives more than one system message.
This causes compatibility issues with agentic clients such as OpenCode, which may send multiple system messages containing agent instructions, tool context, and other configuration.
The request fails with:
system message must be at the beginning
Environment
Model: qwen3.8:27b
Architecture: qwen35
Quantization: Q4_K_M
Ollama server: 0.32.13
OpenCode: 1.18.18
API: OpenAI-compatible /v1/chat/completions
ollama show qwen3.8:27b reports:
Capabilities
completion
vision
tools
thinking
The generated Modelfile uses the native Qwen 3.8 renderer:
TEMPLATE {{ .Prompt }}
RENDERER qwen3.8
PARSER qwen3.5
Reproduction
This can be reproduced directly against Ollama, without OpenCode:
curl -s http://localhost:11434/v1/chat/completions
-H "Content-Type: application/json"
-d '{
"model": "qwen3.8:27b",
"messages": [
{"role":"system","content":"System instruction one."},
{"role":"system","content":"System instruction two."},
{"role":"user","content":"Say hello"}
],
"stream": false
}'
Actual result
{
"error": {
"message": "system message must be at the beginning",
"type": "api_error",
"param": null,
"code": null
}
}
Expected result
Ollama should accept multiple system messages, or merge consecutive/initial system messages before passing them to the Qwen 3.8 renderer.
For example:
system: instruction one
system: instruction two
user: hello
could internally become:
system: instruction one + instruction two
user: hello
OpenCode impact
OpenCode uses Ollama through the OpenAI-compatible provider:
{
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "http://localhost:11434/v1"
}
}
Qwen 3.8 consequently fails immediately with:
Build · Qwen3.8 27B
system message must be at the beginning
Other Ollama models using the same OpenCode configuration do not exhibit this issue.
Confirmed workaround
I created a small HTTP proxy between OpenCode and Ollama that collects all system messages, merges them into a single system message at position 0, and forwards the resulting request unchanged to Ollama.
Architecture:
OpenCode
↓
Compatibility proxy
↓
Merge system messages
↓
Ollama
↓
Qwen 3.8
With this transformation:
system → system → user
becomes:
system → user
and qwen3.8:27b works correctly in OpenCode.
Because the failure can be reproduced directly against /v1/chat/completions, this appears to be an issue with the Qwen 3.8 renderer/message handling rather than OpenCode itself.
It would be useful if the native qwen3.8 renderer could handle multiple system messages, especially for compatibility with OpenAI-compatible agentic clients.
Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.