Topic 5 of 5 · 4 min read
Pointing coding tools at local models
Goal: Configure a coding assistant to use a local model and state which tasks to keep on a hosted model.
A coding assistant can use a local model if the tool supports a custom OpenAI-compatible endpoint, but it needs a long context and still falls short on large, multi-file work.
Check yourself · 1 of 3
An editor assistant on a local model ignores the project's rules file, which is the first part of its prompt. What should you check first?
Why it matters
Local models keep source code on your machine, work offline and cost nothing per token. For code under strict confidentiality that can decide the matter. The trade-off is quality and context: an assistant that sends your open files, search results and tool output needs room for them.
How to do it
- Choose a coding-tuned model that fits your memory, and pull it into a runner such as Ollama, LM Studio or llama-server.
- Raise the runner's context length. Editor assistants and agents can send tens of thousands of tokens; a small default silently truncates the files and the instructions at the start.
- In the tool's settings, add a provider with a base URL, an API key placeholder and a model name. Continue, Cline, Aider, Zed and other tools accept this. The setting names differ, so follow each tool's docs.
- Use different models for different jobs. A small fast model suits autocomplete; a larger model suits chat and edits.
- Test with one real task and check the token count the tool reports against your context setting.
# example shape of an assistant's model entry; field names differ by tool
models:
- name: local-coder
provider: openai-compatible
apiBase: http://localhost:11434/v1
model: qwen2.5-coder:7b
contextLength: 32768
Where a local model falls short
Local models handle small, well-scoped work well: completing a function, writing a test for a pure function, explaining a snippet, a regex, a shell one-liner. They struggle with long agent loops, large refactors across many files, subtle design questions and reliable tool calls over many steps. A failed step early in a loop tends to compound.
A practical split: keep routine edits and anything confidential local; send hard architecture questions, big migrations and long-running agent tasks to a hosted model, with confidential files excluded.
Before and after
Before: The assistant points at a local model with the default context. Edits ignore the instructions in the rules file because the start of the prompt was cut.
After: The context is raised to fit the files, the rules file is the first thing the tool counts, and the task list says which jobs run locally and which go to a hosted model.
What goes wrong
- Memory runs out when context is raised on a large model, and the runner crashes or slows to a crawl.
- The assistant's diffs look plausible but miss the project's conventions. Review them like any other AI diff.
- A tool is set to "auto-run commands" with a model that makes tool-call mistakes. Keep approvals on.
Examples
A split policy
A team keeps autocomplete, test writing and explanations on a local coder model, and uses a hosted model for cross-service refactors. Files in the secrets/ and customers/ folders are excluded from hosted requests in the tool's ignore list.
Instructions that never arrived
An agent ignores its rules file when run on a local model. The tool's debug view shows the prompt was 18,000 tokens and the runner's context was smaller, so the start was dropped. Raising the context fixed it without changing the model.
Key points
- Editor assistants and agents that accept an OpenAI-compatible endpoint can use a local model through a base URL and model name.
- Raise the runner's context length, because these tools send many files and a small default truncates silently.
- Use a small fast model for autocomplete and a larger one for chat and edits.
- Local models suit small scoped tasks and confidential code; long agent loops and large refactors are weaker.
- Keep command approvals on and review local-model diffs like any AI change.
Common mistakes
- Leaving the runner's default context and blaming the model for ignored instructions.
- Using one big model for autocomplete and waiting seconds for each suggestion.
- Giving a local model unrestricted auto-run for shell commands.
- Assuming a local model matches a hosted frontier model on multi-file work.
Check yourself · 2 of 3
Which task is the best fit for a small local coding model?
Check yourself · 3 of 3
Your team has confidential code and also needs help with a hard architecture question. What is a sensible policy?
Practice items, not counted towards your mastery.
Start here
- Ollama: OpenAI compatibility (opens in a new tab)DocsFree
Lists the endpoints and request fields Ollama accepts through its OpenAI-style API, and what is not supported.
- llama.cpp server README (opens in a new tab)DocsFree
Flags and endpoints of llama-server, including its OpenAI-compatible routes and JSON schema options.
- vLLM: structured outputs (opens in a new tab)DocsFree
How vLLM constrains output to a JSON schema, regex or grammar.