Skip to content

Unable to generate files when using local Ollama #29996

Closed as not planned
Closed as not planned

Description

@StrongKelvin

Question

OpenCode 1.15.12
I self-hosted Ollama locally using Docker and installed the gemma4 model. I also configured the Ollama provider in OpenCode under C:\Users<UserName>.config\opencode.
{ "$schema": "https://opencode.ai/config.json", "plugin": ["opencode-antigravity-auth@latest"], "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "name": "Ollama (local)", "options": { "baseURL": "http://localhost:11434/v1" }, "models": { "gemma4:26b": { "name": "gemma4:26b" }, "deepseek-r1:8b": { "name": "deepseek-r1:8b" } } } } }

In OpenCode, I can successfully connect to the self-hosted Ollama and use the gemma4 model. However, there is one issue: in an OpenCode conversation, I want it to help me build a web page, but instead of generating files, it only displays the code in the chat window.

Am I missing some configuration, or is there an additional setting required?

Activity

  1. github-actions commented on May 30, 2026

    @github-actions
    Contributor

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

    These issues share the same root cause: local models via Ollama often lack reliable tool-calling support, causing write/edit tool calls to be printed as JSON in the chat instead of being executed. The behavior you're seeing is a known limitation with some local models that don't properly support the function/tool calling protocol required by OpenCode.

  2. spitzerd commented on Jun 7, 2026

    @spitzerd

    Gemma4 and Gemini are closely related, see https://blog.google/innovation-and-ai/technology/developers-tools/gemma-4/
    In OpenCode, there is a lot of Gemini specific code. For example, there is a specific system prompt for Gemini, see https://github.com/anomalyco/opencode/blob/dev/packages/opencode/src/session/system.ts#L28

    I fixed the issue as follows:

    1. Create modelfile gemma4
    FROM gemma4:12b
    PARAMETER num_ctx 64000
    PARAMETER temperature 1.0
    PARAMETER top_k 64
    PARAMETER top_p 0.95
    
    1. Run ollama create gemini-gemma4:12b -f gemma4
    2. Run ollama launch opencode --model gemini-gemma4:12b

    My opencode.jsonc is empty.
    This way, OpenCode threats Gemma4 as Gemini model.

  3. rekram1-node commented on Jun 23, 2026

    @rekram1-node
    Contributor

    Automated: closing question issues.

    GitHub Issues are for bug reports and feature requests only — questions / support are no longer tracked here.

    If this is a bug or feature request, please open a new issue with the appropriate template.

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