Run a local AI coding agent in VS Code with Ollama
A local model keeps your code on your computer and costs nothing per request. This guide connects Ollama to Phew in VS Code, with the settings that make a local model work well as an agent.
What you need
A coding agent reads files, runs commands, and calls tools, so it needs a model that supports tool calling. Models of about 20 to 30 billion parameters work well on a computer with a modern GPU or with 32 GB of unified memory. Smaller models run on less, but make more mistakes. Be honest with yourself: a local model is slower and weaker than the best cloud models, and great for privacy and cost.
1. Install Ollama
Download Ollama from ollama.com for macOS, Windows, or Linux, and start it. It serves an API on http://localhost:11434.
2. Download a model with tool calling
In the Ollama library, models that can call tools have the tools tag. For example:
ollama pull gpt-oss:20b
ollama pull qwen3-coder
3. Give the model a larger context
An agent sends the files it reads, the tool results, and the chat. The default context of Ollama is small for that. Start Ollama with a larger one:
OLLAMA_CONTEXT_LENGTH=32768 ollama serve
On Windows, set OLLAMA_CONTEXT_LENGTH as an environment variable and restart Ollama.
4. Connect it in Phew
- Open the Phew view and choose Ollama on the first card, or run Phew: Connect a Model.
- The address is
http://localhost:11434/v1. Phew loads the list of your models; pick one. - Click Connect and test. Phew checks that the model answers and that tool calls work.
- In Settings → Models, open ⋯ on the card of the model and set Context window to the same number, for example 32768, so the context meter and compaction fit.
LM Studio and vLLM
- LM Studio: load a model, start the server in the Developer tab, and choose LM Studio in Phew (
http://localhost:1234/v1). - vLLM or another OpenAI-compatible server: choose vLLM or another local server (
http://localhost:8000/v1by default).
Keep it private
- Phew allows plain HTTP only for localhost and private networks, and collects no telemetry.
- A fallback model in the cloud would send your code there when the local model fails. For private code, give a local model no cloud fallback.
- Phew never reads
.envfiles and keys, with a local model or not.
Tips for local models
- Use Ask or Plan mode for questions: they never change a file.
- Give clear, small tasks. Local models do better with one step at a time.
- Set a check command, such as
npm test, inphew.verify.command. Phew runs it after each change and lets the model fix what fails.