Using OpenCode with Local Models on an Old Intel Mac
A practical guide to running an isolated autonomous coding agent with native Ollama inference on an old Intel MacBook Pro.

Current agent stacks such as Codex and Claude Code are powerful, but they can get expensive for everyday experimentation and repeated coding loops. For many tasks, a local setup can be good enough, especially when the goal is drafting, refactoring, exploring a codebase, or running small autonomous workflows completely offline. The technical hurdle multiplies when deploying containerized agent environments alongside local inference engines on legacy architectures.
This post summarizes a deep-dive troubleshooting session mapping an isolated autonomous agent, OpenCode, to a native local large language model engine, Ollama, running entirely on a 2019/2020 Intel-based MacBook Pro with 32 GB of RAM.
Part 1: The Architectural Breakdown and Reality Check
Autonomous agents execute commands, run scripts, install dependencies, and modify workspaces. Keeping the agent inside an isolated Docker container ensures that destructive operations or runaway code loops remain sandboxed and unable to alter your primary operating system.
When designing a secure, offline AI workspace, a common question arises: if my autonomous agent runs inside a Docker container for security, should the LLM engine run inside Docker too?
The answer is no. Keeping the inference engine native to the host machine allows it direct, zero-overhead access to system memory and graphics pipelines. The coding agent itself, however, should be containerized.
The Intel Hardware Constraints
While an Apple Silicon Mac features unified memory architectures optimized for local models, a legacy Intel MacBook Pro relies mostly on its multi-core CPU for processing large neural layers. In practice, I ran into two core limitations:
- Processing overhead: Running a standard 7-billion parameter coding model,
qwen2.5-coder:7b, pushes the Intel CPU cores to 100% capacity. This results in intense system heat, high fan speeds, and processing times of over 3 minutes per execution loop. - Context window truncation: OpenCode wraps standard user requests in comprehensive system instructions containing thousands of hidden configuration tokens. When using large models locally, these complex instructions quickly breach default context limits, causing Ollama to drop tokens and causing the agent to hang indefinitely.
The Solution: Task-Specific Small Language Models
The breakthrough occurred when I shifted from general coding engines to compact, targeted models optimized for specific task workflows:
- For coding and engineering:
qwen2.5-coder:1.5bhandles file automation loops up to 8 times faster, keeping the CPU cool and responses under 15 seconds. - For creative writing and copywriting:
llama3.2:latest, a 3B model, provides linguistic nuance and Markdown formatting while running at a usable 15 tokens per second on legacy Intel chips.
Part 2: Step-by-Step Implementation Guide
This guide walks through configuring an isolated Docker agent to communicate with a native Ollama interface across your Mac’s internal host loopback, bypassing the network drops common to legacy Docker Desktop virtualization.
Step 1: Install and Initialize Ollama Natively
Download and install the native application layer to manage the model assets outside of the container sandbox.
- Download the Mac application from the official site: ollama.com.
- Launch the application to initialize the system menu tools.
- Open a native Mac terminal window and download the writing-optimized model and the coding model:
ollama run llama3.2
ollama run qwen2.5-coder:1.5b
- Once the loading sequence finishes and the chat prompt appears, type
/exitand press Enter to return to your standard terminal path.
Step 2: Configure Docker Desktop System Resources
Autonomous agents run compilation pipelines and parse codebase structures, requiring significant memory overhead within their virtualized Linux containers.
Make sure Docker Desktop for Mac is installed before continuing.
- Open the Docker Desktop application interface.
- Click the gear icon in the upper right corner.
- Navigate to Resources > Advanced or the virtual machine layout.
- Adjust your allocations to the following values:
- CPUs: 3, leaving one core free so your macOS UI remains responsive.
- Memory: 12 GB or 16 GB, allocating about half of your 32 GB RAM pool to the agent.
- Disk usage limit: 32 GB or 64 GB, providing room for project dependencies such as
node_modules.
- Click Apply & restart to cycle the virtualization machine.
Step 3: Create an Isolated Project Environment
Set up a distinct workspace folder on your Desktop to safely isolate the files the AI will interact with.
- Run the following commands in your Mac terminal to generate an empty playground:
cd ~/Desktop
mkdir opencode-test
cd opencode-test
- Initialize Git tracking inside the folder so you can review any code changes the agent executes:
git init
Step 4: Write the Local Connection Schema
Because legacy Docker on Intel architectures cannot reliably parse local Wi-Fi routing paths, we can bypass the cloud registration screens by hardcoding an internal host gateway route using a local configuration file.
Create a configuration file named opencode.json inside your opencode-test directory:
cat << 'EOF' > opencode.json
{
"$schema": "https://opencode.ai",
"provider": {
"ollama": {
"npm": "@ai-sdk/openai-compatible",
"name": "Ollama",
"options": {
"baseURL": "http://host.docker.internal:11434/v1"
},
"models": {
"qwen2.5-coder:7b": {
"name": "qwen2.5-coder:7b"
},
"qwen2.5-coder:1.5b": {
"name": "qwen2.5-coder:1.5b"
},
"llama3.2:latest": {
"name": "llama3.2:latest"
}
}
}
},
"model": "ollama/qwen2.5-coder:1.5b"
}
EOF
Step 5: Launch the Network Loopback and Boot the Agent
To ensure the container can communicate back to your Mac without triggering firewall errors, configure the background engine to listen locally, then boot the agent using an explicit host-gateway bridge.
- In your first terminal window, stop any active processes and start the Ollama server explicitly mapped to your local interface loopback:
OLLAMA_HOST=0.0.0.0:11434 ollama serve
Keep this terminal window running in the background.
- Open a second terminal window, navigate back to your workspace, and launch the isolated OpenCode container using the host routing shortcut:
docker run -it --rm \
--add-host=host.docker.internal:host-gateway \
-v "$(pwd)":/workspace \
-w /workspace \
ghcr.io/anomalyco/opencode:latest
Step 6: Initialize Your Writing Workspace
Once the OpenCode interface initializes, you can run the system initialization script to build your background structures:
/init
You can now issue complex, automated content creation requests:
Act as an expert copywriter. Create a detailed outline for a blog post about "Why Local AI is the Future of Privacy". Save the outline as a file named blog-outline.md inside this workspace.
The model will process the prompt locally and write the resulting Markdown document directly to your Mac’s inside a fully sandboxed environment.