# opencode setup with ollama

A step-by-step guide and Docker Compose setup for configuring OpenCode's agentic workflow to work with local Ollama models, including the context-window fix needed to make Ollama's tool-calling actually function.

This repository documents how to run Ollama in Docker Compose alongside OpenCode and points out a specific problem the author ran into: Ollama defaults to a 4,096-token context window regardless of what a model's card advertises, and OpenCode's agentic tool calls silently fail to work at that size. The fix shown is to run the model interactively, set a larger num_ctx parameter such as 16384, and save it as a new named model variant, then reference that variant in OpenCode's provider configuration pointed at Ollama's OpenAI-compatible endpoint.

It also documents a common cause of OpenCode hanging against Ollama on Windows: localhost resolving to the IPv6 loopback address instead of IPv4, since Ollama on Windows binds only to the IPv4 address.

Website: https://github.com/p-lemonish/ollama-x-opencode
