Skip to content

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

Closed as not planned

Description

@lowcoordination

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"}

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Dec 7, 2025
  2. github-actions commented on Dec 7, 2025

    @github-actions
    Contributor

    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.

  3. lowcoordination commented on Dec 7, 2025

    @lowcoordination
    Author

    looks like it could be related to #5028

  4. rekram1-node commented on Dec 7, 2025

    @rekram1-node
    Contributor

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

  5. removed
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Dec 7, 2025
  6. cgilly2fast commented on Dec 7, 2025

    @cgilly2fast
    Contributor

    I just posted about what seems like a similar issue: #5210

  7. DevGiuDev commented on Dec 8, 2025

    @DevGiuDev

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

  8. minger0 commented on Dec 10, 2025

    @minger0

    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                 
    
  9. minger0 commented on Dec 10, 2025

    @minger0

    @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

  10. self-assigned this
    on Dec 10, 2025
  11. rekram1-node commented on Dec 10, 2025

    @rekram1-node
    Contributor

    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

  12. minger0 commented on Dec 11, 2025

    @minger0

    @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?

  13. minger0 commented on Dec 11, 2025

    @minger0

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

  14. rekram1-node commented on Dec 11, 2025

    @rekram1-node
    Contributor

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

  15. lowcoordination commented on Dec 11, 2025

    @lowcoordination
    Author

    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.

  16. minger0 commented on Dec 12, 2025

    @minger0

    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.

  17. lowcoordination commented on Dec 12, 2025

    @lowcoordination
    Author
  18. minger0 commented on Dec 13, 2025

    @minger0

    @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?

  19. minger0 commented on Dec 13, 2025

    @minger0

    @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.

  20. jverkoey commented on Dec 29, 2025

    @jverkoey

    This seems to still be broken in Ollama 0.13.5.

  21. jverkoey commented on Dec 30, 2025

    @jverkoey

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

  22. thdxr commented on Mar 25, 2026

    @thdxr
    Member

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions