You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ollama: User message content arrives as empty array - model cannot see user input #5187
When using opencode with Ollama via the @ai-sdk/openai-compatible provider, the model receives user messages as empty
arrays instead of the actual text content. The model can see the system prompt but not the user's input.
Environment
opencode version: 1.0.134
Ollama version: 0.13.0
OS: Fedora Linux (kernel 6.17.9-300.fc43.x86_64)
Provider package: @ai-sdk/openai-compatible
Config
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ollama": {
"npm": "@ai-sdk/openai-compatible",
"name": "Ollama (Docker)",
"options": {
"baseURL": "http://localhost:11434/v1"
},
"models": {
"qwen2.5-coder:14b": {
"name": "Qwen 2.5 Coder 14B",
"tools": true
}
}
}
},
"model": "ollama/qwen2.5-coder:14b"
}
Steps to Reproduce1. Configure opencode with Ollama as shown above2. Start opencode and send any message, e.g.: "Explain vectorized operations in pandas"3. Observe the model's responseExpected BehaviorModel responds to the user's question about pandas.Actual BehaviorModel responds with one of:- Raw JSON tool calls: {"name": "todoread", "arguments": {}}- "I notice your message contains an empty array"- Responses to the system prompt only, ignoring user inputExample response:Got it. I'm in read-only plan mode. I'll analyze the user's request...Hello! I notice you've provided an empty array as your input.Verification- Ollama works correctly when called directly via curl:curl http://localhost:11434/v1/chat/completions -d '{"model": "qwen2.5-coder:14b",
"messages": [{"role": "user", "content": "Hello"}]
}'# Returns proper response- Issue persists with tools: false and without reasoning flag- Issue affects both Plan and Build modes- Other CLI tools (e.g., XandAI-CLI, aider) work correctly with the same Ollama setupLikely CauseThe AI SDK appears to be formatting message content as a multimodal array format, but sending empty content. The modelreceives something like:
{"role": "user", "content": []}
instead of:
{"role": "user", "content": "user's actual message"}
These issues all involve problems with how the AI SDK formats and sends message content to OpenAI-compatible endpoints. Your issue specifically describes message content arriving as empty arrays instead of actual text, which appears to be a related message formatting problem.
Feel free to ignore if none of these address your specific case.
I'm not familiar enough with ollama to be best here, but it's not like we aren't sending certain messages, something is happening on the ollama side where it drops content before it gets to llm. Now typically that is num_context not being set to a good value, on the ollama side.
Last I checked you still cant set it from the openai compatible endpoint so its on u to set it
@rekram1-node as @lowcoordination pointed out, it may be because of the message formatting, i.e. array (observed) vs plain string (expected), do you recognize that?
Did ollama ship a breaking change or something? I feel like people had opencode working w/ their setups for a while idk why we would need a new format....
Like I said im not super familiar w/ ollama so I will need to investigate further just trying to figure out why it would stop working all the sudden...
hey sorry it took me a minute to get back here. i believe i had the context set to 16k as i figured agentic work would require a larger window. and i didnt have this problem all of a sudden I never really got it to work but i only started messing with it a couple of days before this happened.
No sorry if I wasn’t clear. I never got it to work. I Took a couple different passes at it but I never got the output to work
Thanks,
Nick Krestakos
Sent from [Proton Mail](https://proton.me/mail/home) for iOS.
Activity
github-actions commentedon Dec 7, 2025
This issue might be a duplicate of existing issues. Please check:
These issues all involve problems with how the AI SDK formats and sends message content to OpenAI-compatible endpoints. Your issue specifically describes message content arriving as empty arrays instead of actual text, which appears to be a related message formatting problem.
Feel free to ignore if none of these address your specific case.
lowcoordination commentedon Dec 7, 2025
looks like it could be related to #5028
rekram1-node commentedon Dec 7, 2025
@lowcoordination what's the context size you have set for ollama? it defaults to 4k or something and that makes it unusable
cgilly2fast commentedon Dec 7, 2025
I just posted about what seems like a similar issue: #5210
DevGiuDev commentedon Dec 8, 2025
Same issue here. Just noticed abotu this project, isntalled and cloud models works perfectly but local llm not.
minger0 commentedon Dec 10, 2025
same issue here
.config/opencode/opencode.json:
minger0 commentedon Dec 10, 2025
@rekram1-node see context length for model, I expect ollama uses that of the model and defaults only when it is left undefined
rekram1-node commentedon Dec 10, 2025
I'm not familiar enough with ollama to be best here, but it's not like we aren't sending certain messages, something is happening on the ollama side where it drops content before it gets to llm. Now typically that is
num_contextnot being set to a good value, on the ollama side.Last I checked you still cant set it from the openai compatible endpoint so its on u to set it
minger0 commentedon Dec 11, 2025
@rekram1-node as @lowcoordination pointed out, it may be because of the message formatting, i.e. array (observed) vs plain string (expected), do you recognize that?
minger0 commentedon Dec 11, 2025
What I can confirm is that the ollama docs have got only examples with plain strings. See also link.
rekram1-node commentedon Dec 11, 2025
Did ollama ship a breaking change or something? I feel like people had opencode working w/ their setups for a while idk why we would need a new format....
Like I said im not super familiar w/ ollama so I will need to investigate further just trying to figure out why it would stop working all the sudden...
lowcoordination commentedon Dec 11, 2025
hey sorry it took me a minute to get back here. i believe i had the context set to 16k as i figured agentic work would require a larger window. and i didnt have this problem all of a sudden I never really got it to work but i only started messing with it a couple of days before this happened.
minger0 commentedon Dec 12, 2025
https://github.com/sst/opencode/blob/9d73096db0ea2eb9e11c48b287855574651f33af/packages/opencode/src/agent/agent.ts#L259 it looks to me that the agent.ts did not change in this respect in the last 5 months, which was also the first version, and neither saw I changes in ollama, which would imply that ollama has never worked in agent mode. I need to add that this is the first time I checked the code base of both projects. @lowcoordination do you mean to suggest it used to work in agent mode?
Looking forward to seeing Augstif's change.
lowcoordination commentedon Dec 12, 2025
minger0 commentedon Dec 13, 2025
@rekram1-node the preliminary conclusion is that the ollama agent mode has never worked, and that applying a string conversion on item in
https://github.com/sst/opencode/blob/9d73096db0ea2eb9e11c48b287855574651f33af/packages/opencode/src/agent/agent.ts#L259
could potentially resolve the issue. Do you think you can help us from here?
minger0 commentedon Dec 13, 2025
@rekram1-node feiskyer/chatgpt-copilot#591 (comment) could be also relevant. If I get this right, the openai and ollama v1 became incompatible, while ollama v2 api is compatible again.
jverkoey commentedon Dec 29, 2025
This seems to still be broken in Ollama 0.13.5.
jverkoey commentedon Dec 30, 2025
The steps in https://github.com/p-lemonish/ollama-x-opencode seem to fix this fwiw
thdxr commentedon Mar 25, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.