From installing Ollama to launching OpenCode with a local model, step by step.
This guide explains how to build a fully local AI coding agent by integrating Ollama, Google's Gemma 4, and OpenCode to ensure data privacy, cost control, and local experimentation. The workflow involves installing Ollama to serve the edge-optimized `gemma4:e4b` model, setting up OpenCode as the agent runtime via npm, and linking them through a local API configuration with a 128K context window. This setup provides a capable, offline development assistant that handles code generation, repository analysis, and file operations without transmitting any data to the cloud.
* **Core Stack:** Uses Ollama for model serving, Gemma 4 (`gemma4:e4b`) as the local LLM, and OpenCode as an open-source agent interface.
* **Setup Steps:** Install Ollama, pull the Gemma 4 model, install OpenCode via `npm install -g opencode-ai`, and connect them by creating a Modelfile for the context window and configuring `opencode.json`.
* **Capabilities:** The local agent supports 128K context, enables coding tasks and workspace automation, and operates entirely offline for maximum security.
A comprehensive technical guide on setting up a high-performance local large language model environment for agentic coding tasks. The author demonstrates how to run a quantized Qwen3.5-27B model on a remote RTX 4090 workstation and access it from a MacBook using Tailscale, integrating the setup with OpenCode and Codex.
Key topics include:
* Step-by-step llama.cpp build configuration for CUDA support.
* Using Tailscale to create a secure network between client and GPU machine.
* Optimizing VRAM usage through specific quantization (UD-Q4_K_XL) and context size management.
* Implementing a corrected chat template to prevent tool-calling errors in agentic workflows.
* Performance insights regarding hybrid architectures and KV cache precision.