Ollama: User message content arrives as empty array - model cannot see user input #3367

Open
opened 2026-02-16 17:39:47 -05:00 by yindo · 18 comments
Owner

Originally created by @lowcoordination on GitHub (Dec 6, 2025).

Originally assigned to: @rekram1-node on GitHub.

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 Reproduce

1. Configure opencode with Ollama as shown above
2. Start opencode and send any message, e.g.: "Explain vectorized operations in pandas"
3. Observe the model's response

Expected Behavior

Model responds to the user's question about pandas.

Actual Behavior

Model 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 input

Example 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 setup

Likely Cause

The AI SDK appears to be formatting message content as a multimodal array format, but sending empty content. The model
receives something like:
{"role": "user", "content": []}
instead of:
{"role": "user", "content": "user's actual message"}
Originally created by @lowcoordination on GitHub (Dec 6, 2025). Originally assigned to: @rekram1-node on GitHub. 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 ```json { "$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 Reproduce 1. Configure opencode with Ollama as shown above 2. Start opencode and send any message, e.g.: "Explain vectorized operations in pandas" 3. Observe the model's response Expected Behavior Model responds to the user's question about pandas. Actual Behavior Model 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 input Example 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 setup Likely Cause The AI SDK appears to be formatting message content as a multimodal array format, but sending empty content. The model receives something like: {"role": "user", "content": []} instead of: {"role": "user", "content": "user's actual message"}
Author
Owner

@github-actions[bot] commented on GitHub (Dec 6, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #5028: Call Missing content in messages - similar issue with empty content blocks in messages sent to OpenAI SDK
  • #5104: Model in @ai-sdk/openai sdk fails on the 2nd request - issue with @ai-sdk/openai SDK message handling
  • #4255: OpenCode v1.0.25 Hangs Indefinitely with LM Studio + Qwen Models Due to Empty tool_calls Array - related issue with OpenAI-compatible providers handling empty tool_calls arrays, causing hangs

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.

@github-actions[bot] commented on GitHub (Dec 6, 2025): This issue might be a duplicate of existing issues. Please check: - #5028: Call Missing content in messages - similar issue with empty content blocks in messages sent to OpenAI SDK - #5104: Model in @ai-sdk/openai sdk fails on the 2nd request - issue with @ai-sdk/openai SDK message handling - #4255: OpenCode v1.0.25 Hangs Indefinitely with LM Studio + Qwen Models Due to Empty tool_calls Array - related issue with OpenAI-compatible providers handling empty tool_calls arrays, causing hangs 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.
Author
Owner

@lowcoordination commented on GitHub (Dec 7, 2025):

looks like it could be related to #5028

@lowcoordination commented on GitHub (Dec 7, 2025): looks like it could be related to #5028
Author
Owner

@rekram1-node commented on GitHub (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

@rekram1-node commented on GitHub (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
Author
Owner

@cgilly2fast commented on GitHub (Dec 7, 2025):

I just posted about what seems like a similar issue: https://github.com/sst/opencode/issues/5210

@cgilly2fast commented on GitHub (Dec 7, 2025): I just posted about what seems like a similar issue: https://github.com/sst/opencode/issues/5210
Author
Owner

@DevGiuDev commented on GitHub (Dec 8, 2025):

Same issue here. Just noticed abotu this project, isntalled and cloud models works perfectly but local llm not.

@DevGiuDev commented on GitHub (Dec 8, 2025): Same issue here. Just noticed abotu this project, isntalled and cloud models works perfectly but local llm not.
Author
Owner

@minger0 commented on GitHub (Dec 10, 2025):

same issue here

opencode version: 1.0.142
Ollama version: 0.13.2
OS: Ubuntu 24.04.3 (kernel 6.8.0-88-generic)
Provider package: @ai-sdk/openai-compatible

.config/opencode/opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama (local)",
      "options": {
        "baseURL": "http://localhost:11434/v1"
      },
      "models": {
        "hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:UD-Q4_K_XL": {
          "name": "hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:UD-Q4_K_XL"
        }
      }
    }
  },
  "model": "ollama/hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:UD-Q4_K_XL"
}
$ ollama show hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:UD-Q4_K_XL
  Model
    architecture        qwen3moe    
    parameters          30.5B       
    context length      262144      
    embedding length    2048        
    quantization        unknown     

  Capabilities
    completion    
    tools         

  Parameters
    repeat_penalty    1.05              
    top_k             20                
    top_p             0.8               
    stop              "<|im_start|>"    
    stop              "<|im_end|>"      
    temperature       0.7               
    min_p             0                 
@minger0 commented on GitHub (Dec 10, 2025): same issue here opencode version: 1.0.142 Ollama version: 0.13.2 OS: Ubuntu 24.04.3 (kernel 6.8.0-88-generic) Provider package: @ai-sdk/openai-compatible .config/opencode/opencode.json: ``` { "$schema": "https://opencode.ai/config.json", "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "name": "Ollama (local)", "options": { "baseURL": "http://localhost:11434/v1" }, "models": { "hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:UD-Q4_K_XL": { "name": "hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:UD-Q4_K_XL" } } } }, "model": "ollama/hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:UD-Q4_K_XL" } ``` ``` $ ollama show hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:UD-Q4_K_XL Model architecture qwen3moe parameters 30.5B context length 262144 embedding length 2048 quantization unknown Capabilities completion tools Parameters repeat_penalty 1.05 top_k 20 top_p 0.8 stop "<|im_start|>" stop "<|im_end|>" temperature 0.7 min_p 0 ```
Author
Owner

@minger0 commented on GitHub (Dec 10, 2025):

@lowcoordination what's the context size you have set for ollama? it defaults to 4k or something and that makes it unusable

@rekram1-node see context length for model, I expect ollama uses that of the model and defaults only when it is left undefined

@minger0 commented on GitHub (Dec 10, 2025): > [@lowcoordination](https://github.com/lowcoordination) what's the context size you have set for ollama? it defaults to 4k or something and that makes it unusable @rekram1-node see context length for model, I expect ollama uses that of the model and defaults only when it is left undefined
Author
Owner

@rekram1-node commented on GitHub (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_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 commented on GitHub (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_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
Author
Owner

@minger0 commented on GitHub (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 commented on GitHub (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?
Author
Owner

@minger0 commented on GitHub (Dec 11, 2025):

What I can confirm is that the ollama docs have got only examples with plain strings. See also link.

@minger0 commented on GitHub (Dec 11, 2025): What I can confirm is that the [ollama docs](https://github.com/ollama/ollama/blob/main/docs/api.md#chat-request-with-history-with-tools) have got only examples with plain strings. See also [link](https://github.com/ollama/ollama/blob/1c4e85b4df1a8ebcb0f578ea423cc1a0d0adf873/server/prompt.go#L95).
Author
Owner

@rekram1-node commented on GitHub (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...

@rekram1-node commented on GitHub (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...
Author
Owner

@lowcoordination commented on GitHub (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.

@lowcoordination commented on GitHub (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.
Author
Owner

@minger0 commented on GitHub (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.

@minger0 commented on GitHub (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.
Author
Owner

@lowcoordination commented on GitHub (Dec 12, 2025):

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 for iOS.

-------- Original Message --------
On Friday, 12/12/25 at 03:22 minger0 @.***> wrote:

minger0 left a comment (sst/opencode#5187)

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. @.***(https://github.com/lowcoordination) do you mean to suggest it used to work in agent mode?
Looking forward to seeing Augstif's change.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: @.***>

@lowcoordination commented on GitHub (Dec 12, 2025): 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. -------- Original Message -------- On Friday, 12/12/25 at 03:22 minger0 ***@***.***> wrote: > minger0 left a comment [(sst/opencode#5187)](https://github.com/sst/opencode/issues/5187#issuecomment-3645433164) > > 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. ***@***.***(https://github.com/lowcoordination) do you mean to suggest it used to work in agent mode? > Looking forward to seeing Augstif's change. > > — > Reply to this email directly, [view it on GitHub](https://github.com/sst/opencode/issues/5187#issuecomment-3645433164), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/A4VQ53CE7ZUWRB4QWOU4PMT4BJ3KVAVCNFSM6AAAAACOIS6522VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTMNBVGQZTGMJWGQ). > You are receiving this because you were mentioned.Message ID: ***@***.***>
Author
Owner

@minger0 commented on GitHub (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 commented on GitHub (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?
Author
Owner

@minger0 commented on GitHub (Dec 13, 2025):

@rekram1-node https://github.com/feiskyer/chatgpt-copilot/issues/591#issuecomment-3443179072 could be also relevant. If I get this right, the openai and ollama v1 became incompatible, while ollama v2 api is compatible again.

@minger0 commented on GitHub (Dec 13, 2025): @rekram1-node https://github.com/feiskyer/chatgpt-copilot/issues/591#issuecomment-3443179072 could be also relevant. If I get this right, the openai and ollama v1 became incompatible, while ollama v2 api is compatible again.
Author
Owner

@jverkoey commented on GitHub (Dec 29, 2025):

This seems to still be broken in Ollama 0.13.5.

@jverkoey commented on GitHub (Dec 29, 2025): This seems to still be broken in Ollama 0.13.5.
Author
Owner

@jverkoey commented on GitHub (Dec 29, 2025):

The steps in https://github.com/p-lemonish/ollama-x-opencode seem to fix this fwiw

@jverkoey commented on GitHub (Dec 29, 2025): The steps in https://github.com/p-lemonish/ollama-x-opencode seem to fix this fwiw
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3367