Skip to content

ollama integration no results returned #3265

Closed

Description

@delphijc

Having tried a number of different Ollama models all result in no output and an eventual time out.

I have this issue only in opencode all the models work and respond almost immediately either in the terminal or the Ollama UI.

Same short prompt: what is in this directory?

Answer s/b: the directory is empty. as it is a new project.

Result is: timeout

opencode.json is:{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama (local)",
      "options": {
        "baseURL": "http://localhost:11434/v1"
      },
      "models": {
        "llama3.1:8b": {
          "name": "llama3.1"
        },
        "llama3.2:3b": {
          "name": "llama3.2"
        },
        "qwen2.5-coder:7b": {
          "name": "qwen coder"
        },
        "mistral:7b-instruct": {
          "name": "mistral"
        }
      }
    }
  }
}

Activity

  1. github-actions commented on Oct 18, 2025

    @github-actions
    Contributor

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

    The core issue appears to be timeout-related problems with Ollama integration where models work fine outside opencode but fail to return responses when used through opencode.

    Feel free to ignore if none of these address your specific case.

  2. delphijc commented on Oct 18, 2025

    @delphijc
    Author

    issue #2137 is similar to what I am experiencing. It is not exactly the same but similar.

  3. rekram1-node commented on Oct 19, 2025

    @rekram1-node
    Contributor

    I have this issue only in opencode all the models work and respond almost immediately either in the terminal or the Ollama UI.

    so like if you curl you get a response instantly?

    Maybe you can do:

    opencode run hello --print-logs

  4. self-assigned this
    on Oct 19, 2025
  5. delphijc commented on Oct 19, 2025

    @delphijc
    Author

    Thank you for looking into this I have run several tests today. Attached are txt based log files for opencode and ollama server outputs of the tests. In each case I first run "ollama serve > ollama.out.logs 2>&1", then in a separate terminal "ollama ps" to verify no model is loaded, the "ollama run qwen2.5-coder:7b" prompt with hello or sup bro get a response of hello how can I help, then "ollama ps" again to verify the model is running, then "opencode run hello > opencode.logs.out 2>1&" to capture opencode logs. I tried this both with and without starting ollama run qwen2.5-coder:7b, each time with fresh runs of "ollama serve" from cold starts.

    all results ended with very limited or not calls to the /v1 api in ollama serve logs and opencode logs end in timeout.

    I admit to being in relative noob status so if I am overlooking something totally obvious please let me know.

    ollama.logs.out.2.txt

    opencode.logs.out.2.txt

  6. rekram1-node commented on Oct 19, 2025

    @rekram1-node
    Contributor

    @delphijc the only thing I can think of is increasing your timeout?

    You can set a custom timeout like so (this is a 10 minute one):

    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "ollama": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "Ollama (local)",
          "options": {
            "baseURL": "http://localhost:11434/v1",
            "timeout": 600000
          },
          "models": {
            "llama3.1:8b": {
              "name": "llama3.1"
            },
            "llama3.2:3b": {
              "name": "llama3.2"
            },
            "qwen2.5-coder:7b": {
              "name": "qwen coder"
            },
            "mistral:7b-instruct": {
              "name": "mistral"
            }
          }
        }
      }
    }
    
  7. sylvain-billie commented on Oct 20, 2025

    @sylvain-billie

    you need to change the context size.

    To test:

    pkill ollama
    OLLAMA_CONTEXT_LENGTH=32000 ollama serve

    permanent solution is to add the variable to your plist, or modify the model (with modelfile) to use a bigger context

  8. delphijc commented on Oct 21, 2025

    @delphijc
    Author
  9. seefood commented on Oct 21, 2025

    @seefood

    I have the same issue. when I select a local ollama model I either get an immediate error "AI_APICallError: Forbidden" or "AI_APICallError: registry.ollama.ai/library/deepseek-coder-v2:16b does not support tools" (same for startcoder of all versions), but if I use llama or QWEN it just animates the "Generating" and does nothing - I know because ollama ps shows nothing is using it.

    I assume that means OpenCode is just not really ready for Ollama yet.

  10. delphijc commented on Oct 21, 2025

    @delphijc
    Author

    A few things may help:

    1. Make sure the model you want to use has a "tools" tag or it won't work.
    2. In your opencode.json add a "timeout": 600000 tonthe options section after "baseurl": url,
    3. increase the context size to at least 32000. export OLLAMA_CONTEXT_LENGTH=32000, and then start ollama serve.

    These got me to the point where I was receiving results. I have not gotten to the point where I am being productive yet. Maybe after $dayjob this evening. Good luck! #noobsunite

  11. rekram1-node commented on Oct 21, 2025

    @rekram1-node
    Contributor

    lmk if yall run into any issues and if there is anytbung we should change / document better

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