How to Run a Local AI Coding Agent Like Cursor for Free (November 2026)
Yes, you can run a Cursor-style coding agent on your own machine without paying for anything. The setup that works best in November 2026: install Ollama, raise its context window to 64K tokens, pull Qwen3.8 27B (an 18 GB download that wants a 24 GB graphics card or a 32 GB Mac), and connect it to Cline in VS Code. Add llama.vscode or the Zed editor for local tab autocomplete.
It is free and private, but it is not Cursor. A local model is slower, works with a fraction of the context and fumbles tool calls more often than the frontier models behind Cursor and Claude Code. That is why we recommend a hybrid: free local autocomplete and routine agent work, plus a cheap API for the hard tasks. Every command below was checked against each tool’s current docs.
- Best all-round local model
- Qwen3.8 27B (18 GB)
- Context for agents
- 64K tokens minimum
- Sweet-spot hardware
- 24 GB GPU or 32 GB Mac
- Running cost
- $0 after hardware
How coding agents like Cursor and Claude Code work
A coding agent is a loop around a model. The editor or CLI (the “harness”) sends the model your request, a long system prompt and a list of tools: read a file, search, edit, run a command. The model answers with a tool call, the harness runs it and sends back the result, and the loop repeats until the task is done. Our guide to building a Cursor-like coding agent walks through the whole loop.
Two requirements follow, and local setups usually break on them:
- Context. The system prompt, tool definitions and file contents fill the window fast. Ollama’s docs ask for at least 64K tokens for coding tools, Codex and OpenCode both say 64K or more, and LM Studio warns that Claude Code needs more than about 25K.
- Tool calls. The model has to produce a well-formed tool call on every turn. One malformed call and the loop stalls or goes in circles.
What your hardware can run
The rule: the model file plus its context cache must fit in GPU memory. If part of it spills to the CPU, speed collapses. On a Mac, macOS lets the GPU use roughly 75% of unified memory by default, so a 32 GB Mac gives the model about 21–24 GB.
| GPU memory | Example machines | Agent model that fits (Ollama tag, download) | Realistic use |
|---|---|---|---|
| 8–12 GB | 16 GB Mac; RTX 3060 12 GB | Autocomplete: qwen2.5-coder:1.5b-base (986 MB) or :7b-base (4.7 GB). Chat: qwen3.5:9b (6.6–7.6 GB) | Tab completion and questions. Agents struggle. |
| 16 GB | 24 GB Mac; RTX 4060 Ti 16 GB | gpt-oss:20b (14 GB) | Small agent tasks with modest context |
| 24 GB | 32–36 GB Mac; RTX 3090 / 4090 | qwen3.8:27b (18 GB), qwen3.6:35b-a3b (23 GB), devstral-small-2 (15 GB) | The sweet spot. Real agent work at 64K. |
| 32–48 GB | 48–64 GB Mac; RTX 5090 (32 GB); two 24 GB cards | qwen3.8:27b-q8_0 (30 GB), or the 18 GB build with 128K+ context | Same models, higher precision or longer context |
| 64–96 GB | 96–128 GB Mac; multi-GPU workstation | qwen3-coder-next (52 GB), gpt-oss:120b (65 GB) | Larger mixture-of-experts models |
| 128 GB | NVIDIA DGX Spark (128 GB unified) | qwen3-coder-next:q8_0 (85 GB) | Fits big models, but 273 GB/s memory bandwidth limits speed |
| 170 GB+ | 256 GB+ Mac; GPU server | GLM-5.3-Flash (~176 GB at 4-bit), DeepSeek-V4-Flash (167 GB as shipped) | The strongest open models. Usually cheaper through an API. |
Sizes are Ollama download sizes. The context cache needs memory on top, so leave a few GB free. Ollama itself picks a small default context on smaller machines: 4K under 24 GB of VRAM, 32K between 24 and 48 GB.
Best open-weight coding models (November 2026)
| Model | Maker, licence | Size | Ollama tag | Why pick it |
|---|---|---|---|---|
| Qwen3.8 27B | Alibaba Qwen, Apache 2.0, Aug 2026 | 27B dense, 256K context | qwen3.8:27b | Best all-rounder. Qwen reports 61.7 on SWE-bench Pro and 73.0 on Terminal-Bench 2.1, up from 53.5 and 63.4 for Qwen3.6 27B. Thinking is on by default. |
| Qwen3.6 35B-A3B | Qwen, Apache 2.0, Apr 2026 | 35B MoE, 3B active | qwen3.6:35b-a3b | Faster on the same hardware because only 3B parameters work per token. 73.4 SWE-bench Verified (Qwen). OpenHands’ first-choice local model. |
| Devstral Small 2 | Mistral, Apache 2.0, Dec 2025 | 24B dense | devstral-small-2 | Built for agents that explore codebases with tools. 65.8% SWE-bench Verified (Mistral’s figure). |
| gpt-oss-20b | OpenAI, Apache 2.0 | 21B MoE, 3.6B active | gpt-oss:20b | Runs in 16 GB. Codex’s default local model; llama.vscode calls it the best choice for its agent. |
| Qwen3-Coder-Next | Qwen, Apache 2.0, Feb 2026 | 80B MoE, 3B active | qwen3-coder-next | Coding-only, no thinking blocks, 256K context. For 64 GB+. |
| gpt-oss-120b | OpenAI, Apache 2.0 | 117B MoE, 5.1B active | gpt-oss:120b | Fits one 80 GB GPU or a large Mac. |
Benchmark figures are the makers’ own. Qwen ran its SWE-bench Pro tests in the Claude Code harness with a 256K context window; expect less from a 4-bit copy running at 64K on your desk. The strongest open models (GLM-5.3, DeepSeek V4, Kimi K3, MiniMax M3.1) need hundreds of GB; use them through an API.
Recommended setup: Ollama + Cline in VS Code
This is the closest free match to Cursor’s agent: an extension inside VS Code that reads your repo, proposes diffs and runs commands with your approval.
1. Install Ollama
Download it from ollama.com/download (macOS, Windows, Linux). On Apple silicon, Ollama moved its engine to Apple’s MLX framework starting with version 0.19 (March 2026; at launch it asked for a Mac with more than 32 GB). In Ollama’s own test that took a 35B-A3B model from 58 to 112 tokens per second.
2. Set the context length to 64K
In the Ollama app, open Settings and move the context length slider to 64K. From the command line:
# macOS app: set the variable for the app, then quit and reopen Ollama
launchctl setenv OLLAMA_CONTEXT_LENGTH 65536
# Linux, or any machine where you run the server yourself
OLLAMA_CONTEXT_LENGTH=65536 ollama serveSkip this and the agent “forgets” its instructions: Ollama silently drops whatever does not fit the window, and the system prompt goes first.
3. Pull a model that fits
ollama pull qwen3.8:27b # 24 GB GPU or 32 GB Mac
ollama pull gpt-oss:20b # 16 GB4. Check it fits in GPU memory
ollama run qwen3.8:27b "Reply with one word: ready"
ollama psIn the ollama ps output, CONTEXT should read 65536 and PROCESSOR should read 100% GPU. A split such as 48%/52% CPU/GPU means it does not fit: drop to 32K context or a smaller model.
5. Install Cline and point it at Ollama
- In VS Code, open Extensions, search for Cline and install it.
- In Cline’s settings, choose API provider Ollama. The base URL defaults to
http://localhost:11434. - Pick
qwen3.8:27bfrom the model list. - Set Model Context Window to
65536. Cline passes this number to Ollama asnum_ctxwith every request, so it overrides the server setting and must match what fits. - Under Settings › Features, turn on Use Compact Prompt. Cline recommends it for every local model: a shorter system prompt leaves more room for your code.
6. Start small
Open a repo, switch Cline to Plan mode and ask “Read this project and tell me how to run the tests.” Then switch to Act for one contained change, such as adding a test. Unless you turn on auto-approve, Cline asks before each edit and command. Start a new task when the conversation gets long; Cline’s docs say the same.
Prefer the terminal? Claude Code, OpenCode or Codex on a local model
Since January 2026, ollama launch installs and configures terminal agents for you, with no environment variables. Ollama serves an Anthropic-compatible API, so Claude Code talks to your local model instead of Anthropic’s servers.
ollama launch claude --model qwen3.8:27b
ollama launch opencode --model qwen3.8:27b
ollama launch codex
# Codex without the launcher (defaults to gpt-oss:20b)
codex --oss -m gpt-oss:20bThe 64K rule still applies: Ollama’s Claude Code page asks for 64K or more on local models.
Other front-ends and runtimes
| Front-end | Where it runs | Local models | Worth knowing |
|---|---|---|---|
| Cline | VS Code | Ollama, LM Studio | Plan and Act can use different models |
| Kilo Code | VS Code | Ollama, LM Studio, Atomic Chat | Its autocomplete runs Codestral through Kilo’s gateway, billed, not locally |
| Zed | Own editor | Ollama, LM Studio, llama.cpp | Agent and edit prediction both work locally; set context_window, since Zed sends Ollama 4,096 tokens by default |
| Claude Code, OpenCode, Codex | Terminal | Via ollama launch | 64K+ context |
| Aider | Terminal | aider --model ollama_chat/<model> | Sizes Ollama’s context to each request for you |
| OpenHands | Browser, Docker | Ollama or LM Studio over an OpenAI-style URL | Recommends Qwen3.6-35B-A3B and 32,768+ context |
| Ollama for VS Code | VS Code Chat | Ollama | Adds local models to the Chat model picker (VS Code 1.127+) |
| Continue | VS Code, JetBrains | Ollama | Still installs, but the repo has been read-only since its final 2.0 release (June 2026) |
| Roo Code | — | — | Shut down May 15, 2026; repo archived |
| Runtime | Best for | How to set context |
|---|---|---|
| Ollama | Easiest start; MLX engine on Macs, CUDA on NVIDIA | App slider, OLLAMA_CONTEXT_LENGTH, or the agent’s own setting |
| LM Studio | GUI model browser; server on port 1234 with an Anthropic-compatible endpoint | lms load <model> --context-length=65536 |
| llama.cpp | Most control; FIM presets for autocomplete | llama serve -hf ggml-org/Qwen3.8-27B-GGUF -c 65536 |
| MLX | Apple silicon; LM Studio offers MLX builds such as Qwen3.8 27B 4-bit | Set by the app that runs it |
| vLLM, SGLang | NVIDIA servers shared by a team; Qwen recommends them for high throughput | Server flags |
Local tab autocomplete
Autocomplete is a different job from agent work. It uses fill-in-the-middle (FIM): the model sees the code before and after your cursor and predicts the gap. Small base models do this well and fast; large chat models do it badly, as Continue’s docs put it. Our guide to autocomplete models explains how Cursor Tab and Copilot approach it.
Best local autocomplete models right now: the Qwen2.5-Coder base family is still the default. llama.cpp ships one-flag presets for the 1.5B, 3B and 7B versions (plus a 30B preset built on Qwen3-Coder 30B-A3B), and Zed’s docs use qwen2.5-coder:7b-base. Zed’s own next-edit model, Zeta 2.1 (8B, Apache 2.0, fine-tuned from Seed-Coder-8B-Base), also has open weights.
VS Code: llama.vscode
Install the llama-vscode extension. It can install llama.cpp itself and start a completion setup from its menu (Ctrl+Shift+M), or you can start the server yourself with the preset that matches your free GPU memory:
brew install llama.cpp # macOS; Windows: winget install llama.cpp
llama serve --fim-qwen-7b-default # more than 16 GB VRAM
llama serve --fim-qwen-3b-default # less than 16 GB
llama serve --fim-qwen-1.5b-default # less than 8 GBIf your agent model already fills the GPU, use the 1.5B preset for autocomplete.
Zed: agent and autocomplete in one editor
Zed is the closest free all-in-one to Cursor: its agent panel and its edit prediction can both use Ollama, and local edit prediction works on Zed’s free plan. Run ollama pull qwen2.5-coder:7b-base, then add this to Zed’s settings:
{
"edit_predictions": {
"provider": "ollama",
"ollama": {
"api_url": "http://localhost:11434",
"model": "qwen2.5-coder:7b-base",
"prompt_format": "infer",
"max_output_tokens": 512
}
}
}Honest limits vs Cursor and Claude Code
| Local (24 GB, Qwen3.8 27B) | Cursor or Claude Code | |
|---|---|---|
| Model | Strong 27B open model | Frontier models (see our best AI for coding ranking) |
| Context | 64K typical, 128K with more memory | Much larger, with prompt caching on the provider’s side |
| Speed | Fine for MoE models; long prompts are slow to read | Datacenter GPUs |
| Tool calls | Depend on model and chat template; more misfires | Model and tool tuned together |
| Cost | $0 after hardware | About $20 a month to start (pricing compared) |
| Privacy | Code never leaves your machine | Code goes to the provider |
- Speed is about reading, not writing. In Ollama’s MLX test a 35B-A3B model generated 112 tokens per second but read prompts at 1,810 per second. At that rate a 30,000-token agent prompt takes about 17 seconds before the first word, and a dense 27B is slower than a 3B-active MoE. Ollama’s newer cache reuse helps on follow-up turns.
- Context runs out. At 64K the agent compacts or loses track on big refactors. Kilo’s docs also note local setups often lack prompt caching.
- Tool calls misfire. Continue’s docs warn that “not all models that claim tool support work correctly.” Symptoms: loops, edits to the wrong file, ignored tool results. Fix: 64K context, compact prompts, smaller tasks.
- Quality gap. Qwen’s own table puts Qwen3.8 27B at 61.7 on SWE-bench Pro against 53.4 for Claude Opus 4.6 Max, but that is Qwen’s own test at 256K context against an older Claude, on different harnesses. Today’s frontier models are further ahead.
The cheap hybrid setup
A practical middle ground costs a few dollars a month:
- Local autocomplete with llama.vscode or Zed: free, private and instant.
- Local agent for routine work: explaining code, writing tests, small edits.
- A paid model for the hard tasks: multi-file refactors, nasty bugs, anything that loops locally.
Three cheap ways to do step 3:
- DeepSeek API.
deepseek-flash(DeepSeek-V4.1-Flash) costs $0.15–$0.30 per million input tokens on a cache miss and $0.60–$1.20 per million output, cheapest off-peak. Ten million uncached input tokens cost $1.50–$3.00. Its Anthropic-compatible endpoint works with Claude Code (DeepSeek’s guide sets a few more variables):
export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
export ANTHROPIC_AUTH_TOKEN=<your DeepSeek API key>
export ANTHROPIC_MODEL=deepseek-flash[1m]
claude- Cline Plan and Act. Turn on Use different models for Plan and Act: plan with a strong API model, act with your local one. Cline’s docs suggest a stronger model for planning and a faster one for implementation.
- Ollama Cloud. The same
ollama launchcommands work with cloud models. Pay-as-you-go has no subscription; Pro is $20 a month with $60 of usage credits. Local models stay unlimited and free.
FAQ
Can I run a Cursor-like AI coding agent locally for free?
Yes. Install Ollama, set its context length to at least 64K tokens, pull an open-weight model such as Qwen3.8 27B, and connect it to a free agent extension such as Cline in VS Code. Everything runs on your machine and costs nothing beyond the hardware, but it is slower and less reliable than Cursor or Claude Code with frontier models.
What is the best local model for agentic coding in November 2026?
For a 24 GB GPU or a 32 GB Mac, Qwen3.8 27B (Apache 2.0, 18 GB in Ollama) is the best all-rounder. Qwen3.6 35B-A3B is faster on the same hardware, gpt-oss-20b is the pick for 16 GB, and Qwen3-Coder-Next or gpt-oss-120b suit machines with 64 GB or more.
What is the best local autocomplete model?
A small fill-in-the-middle base model, not a chat model. Qwen2.5-Coder base at 1.5B, 3B or 7B is still the default: llama.cpp has one-flag presets for each, and Zed’s docs use qwen2.5-coder:7b-base with Ollama. Zed’s own Zeta 2.1 (8B, Apache 2.0) is an open next-edit alternative.
How much RAM or VRAM do I need to run a coding agent locally?
About 24 GB of GPU memory, or a 32 GB Mac, for real agent work with a 27B model at 64K context. 16 GB runs gpt-oss-20b for smaller tasks. Under 16 GB, use local autocomplete and send agent work to a cheap API.
How do coding agents like Cursor or Claude Code work?
They run a loop. The tool sends the model your request, a system prompt and a list of tools such as read file, search, edit and run command. The model answers with a tool call, the tool runs it and returns the result, and the loop repeats until the task is done. That is why local agents need a large context window and a model that makes reliable tool calls.
Why does my local coding agent forget its tools or loop?
Usually the context window is too small. Ollama defaults to 4K tokens on machines with under 24 GB of VRAM and drops anything beyond the window, so the system prompt and tool list get cut. Set 64K in Ollama and in your agent, enable Cline’s Compact Prompt, and keep tasks small.
Sources
Checked November 2026. Benchmark scores are the model makers’ own unless stated; model sizes are Ollama download sizes.
- Ollama docs: Context length (defaults by VRAM, 64K for agents, ollama ps)
- Ollama docs: FAQ (OLLAMA_CONTEXT_LENGTH, launchctl, GPU check)
- Ollama docs: Claude Code
- Ollama docs: Codex
- Ollama docs: OpenCode
- Ollama docs: VS Code extension
- Ollama blog: ollama launch (January 23, 2026)
- Ollama blog: Ollama is now powered by MLX on Apple silicon (March 30, 2026)
- Ollama pricing
- Ollama library: qwen3.8 tags
- Ollama library: qwen3.6 tags
- Ollama library: qwen3-coder-next
- Ollama library: devstral-small-2
- Ollama library: gpt-oss
- Ollama library: qwen3.5
- Ollama library: qwen2.5-coder tags
- Hugging Face: Qwen3.8-27B model card
- Hugging Face: Qwen3.6-35B-A3B model card
- Hugging Face: Zeta 2.1
- Hugging Face: ggml-org Qwen3.8-27B GGUF
- Hugging Face: LM Studio Qwen3.8-27B MLX 4-bit
- VDF AI: Best local LLM for coding (sizes of large open models, updated November 13, 2026)
- Atomic Chat: Best local LLMs for coding (hardware for Qwen3.8 27B)
- macOS Metal GPU memory cap (about 75% of unified memory)
- NVIDIA: DGX Spark hardware overview
- NVIDIA: GeForce RTX 5090
- Cline docs: Running models locally
- Cline docs: Ollama
- Cline docs: Plan and Act
- Cline source: Ollama provider settings (Model Context Window)
- Kilo Code docs: Using local models
- Kilo Code docs: Autocomplete
- Zed docs: Use a local model
- Zed docs: Edit prediction
- Aider docs: Ollama
- OpenHands docs: Local LLMs
- Continue on GitHub (no longer maintained)
- Continue docs: Autocomplete models
- Continue docs: Ollama guide (tool support warning)
- Morph: Roo Code shut down May 15, 2026
- llama.vscode on GitHub
- llama.cpp on GitHub (llama serve quick start)
- llama.cpp server README (FIM presets, context size, Anthropic Messages API)
- LM Studio docs: lms CLI
- LM Studio docs: Claude Code
- DeepSeek API pricing
- DeepSeek docs: Claude Code integration
