Skip to content
CodeSpider
GitHub

Self-Hosted Ollama & Local LLMs

Self-hosting the CodeSpider daemon only keeps repository context private if your llm.base_url also stays inside your network. CodeSpider works with any OpenAI-compatible /v1/chat/completions endpoint that supports structured tool calling, including Ollama, vLLM, and LiteLLM.

Never expose Ollama port 11434 on a public interface. Bind Ollama strictly to 127.0.0.1:11434 on your GPU workstation and forward it over SSH to the CodeSpider host:

Terminal window
# On the GPU workstation: bind strictly to loopback
OLLAMA_HOST=127.0.0.1:11434 \
OLLAMA_CONTEXT_LENGTH=16384 \
OLLAMA_KEEP_ALIVE=60m \
OLLAMA_NUM_PARALLEL=1 \
OLLAMA_FLASH_ATTENTION=1 \
ollama serve

Pull a tool-calling capable model (Stage B was verified with qwen3.8:27b at Q4_K_M):

Terminal window
ollama pull qwen3.8:27b

On the host running CodeSpider, open a persistent local port forward:

Terminal window
ssh -N -o ExitOnForwardFailure=yes -o ServerAliveInterval=30 \
-L 127.0.0.1:11434:127.0.0.1:11434 user@gpu-workstation

These loopback settings work when the daemon runs on the host. Inside Docker or Podman, 127.0.0.1 means the container itself. Use a model endpoint reachable only from the daemon’s private container network, or run the daemon on the host. Do not open the model port publicly to make the container reach it.

Section titled “Recommended codespider.yaml for Local Models”

llm.reasoning_effort and agent.job_timeout_seconds ship in v1.1.0. Only set the reasoning option if your endpoint supports it.

llm:
base_url: "http://127.0.0.1:11434/v1"
api_key: "ollama"
model: "qwen3.8:27b"
timeout_seconds: 600
max_retries: 0
reasoning_effort: "none" # skip hidden thinking tokens on slow hardware
agent:
max_steps: 6
max_tokens_per_run: 24000
job_timeout_seconds: 900 # default is 300; hybrid CPU/GPU 27B needed 4.4-12.6 min per PR
enable_write: false
daemon:
workers: 1

Operational Lessons from Stage B (qwen3.8:27b)

Section titled “Operational Lessons from Stage B (qwen3.8:27b)”

During Stage B validation (Linux workstation, Intel Core i5-10400, 31 GiB RAM, NVIDIA RTX 4060 8 GiB VRAM), we observed the following practical constraints:

Factor Observed Behavior Recommendation
Single-slot queueing qwen3.8:27b (Q4_K_M) uses ~19.0 GB loaded (5.32 GB VRAM, ~29% GPU / ~71% CPU hybrid offload). Keep daemon.workers: 1 and OLLAMA_NUM_PARALLEL=1 so PR jobs never contend for KV cache or swap.
Thinking-token overhead Reasoning tokens increased response time in the recorded hybrid CPU/GPU setup. Try llm.reasoning_effort: "none" if the endpoint supports it. The 26 HTTP 200 responses show transport success, not review accuracy.
Per-job time budget The per-job deadline was a hardcoded 5 minutes at fed7f5c. Hybrid CPU/GPU 27B inference (1.2–2.0 tok/s) took 4.4m–12.6m per PR. Raise agent.job_timeout_seconds. A GPU that holds the whole model in VRAM avoids the problem; we did not test one.

The archived Stage B runs used upstream fed7f5c with two local deviations, both now configurable:

  1. The per-job deadline was raised from 5 to 15 minutes with a one-line source change (now agent.job_timeout_seconds).
  2. A small local proxy added reasoning_effort: "none" to every /v1/chat/completions request, because fed7f5c had no such option (now llm.reasoning_effort).

CodeSpider Operations Console running 5/5 Stage B reviews against qwen3.8:27b

Validate Tool-Calling Before Connecting Repos

Section titled “Validate Tool-Calling Before Connecting Repos”

Use /v1/models to confirm the endpoint advertises your model. This only checks reachability and discovery, not tool calling.

Terminal window
curl -fsS http://127.0.0.1:11434/v1/models

Run a review on a disposable repository before enabling production webhooks. Confirm the daemon can parse tool calls, finish within the configured job timeout, and post the expected result. See the pilot checklist and recorded release run for reference.