How to Run a Local AI Coding Agent Like Cursor for Free (November 2026)

By stackcone · 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:

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 memoryExample machinesAgent model that fits (Ollama tag, download)Realistic use
8–12 GB16 GB Mac; RTX 3060 12 GBAutocomplete: 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 GB24 GB Mac; RTX 4060 Ti 16 GBgpt-oss:20b (14 GB)Small agent tasks with modest context
24 GB32–36 GB Mac; RTX 3090 / 4090qwen3.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 GB48–64 GB Mac; RTX 5090 (32 GB); two 24 GB cardsqwen3.8:27b-q8_0 (30 GB), or the 18 GB build with 128K+ contextSame models, higher precision or longer context
64–96 GB96–128 GB Mac; multi-GPU workstationqwen3-coder-next (52 GB), gpt-oss:120b (65 GB)Larger mixture-of-experts models
128 GBNVIDIA 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 serverGLM-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)

ModelMaker, licenceSizeOllama tagWhy pick it
Qwen3.8 27BAlibaba Qwen, Apache 2.0, Aug 202627B dense, 256K contextqwen3.8:27bBest 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-A3BQwen, Apache 2.0, Apr 202635B MoE, 3B activeqwen3.6:35b-a3bFaster on the same hardware because only 3B parameters work per token. 73.4 SWE-bench Verified (Qwen). OpenHands’ first-choice local model.
Devstral Small 2Mistral, Apache 2.0, Dec 202524B densedevstral-small-2Built for agents that explore codebases with tools. 65.8% SWE-bench Verified (Mistral’s figure).
gpt-oss-20bOpenAI, Apache 2.021B MoE, 3.6B activegpt-oss:20bRuns in 16 GB. Codex’s default local model; llama.vscode calls it the best choice for its agent.
Qwen3-Coder-NextQwen, Apache 2.0, Feb 202680B MoE, 3B activeqwen3-coder-nextCoding-only, no thinking blocks, 256K context. For 64 GB+.
gpt-oss-120bOpenAI, Apache 2.0117B MoE, 5.1B activegpt-oss:120bFits 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 serve

Skip 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 GB

4. Check it fits in GPU memory

ollama run qwen3.8:27b "Reply with one word: ready"
ollama ps

In 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

  1. In VS Code, open Extensions, search for Cline and install it.
  2. In Cline’s settings, choose API provider Ollama. The base URL defaults to http://localhost:11434.
  3. Pick qwen3.8:27b from the model list.
  4. Set Model Context Window to 65536. Cline passes this number to Ollama as num_ctx with every request, so it overrides the server setting and must match what fits.
  5. 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:20b

The 64K rule still applies: Ollama’s Claude Code page asks for 64K or more on local models.

Other front-ends and runtimes

Front-endWhere it runsLocal modelsWorth knowing
ClineVS CodeOllama, LM StudioPlan and Act can use different models
Kilo CodeVS CodeOllama, LM Studio, Atomic ChatIts autocomplete runs Codestral through Kilo’s gateway, billed, not locally
ZedOwn editorOllama, LM Studio, llama.cppAgent and edit prediction both work locally; set context_window, since Zed sends Ollama 4,096 tokens by default
Claude Code, OpenCode, CodexTerminalVia ollama launch64K+ context
AiderTerminalaider --model ollama_chat/<model>Sizes Ollama’s context to each request for you
OpenHandsBrowser, DockerOllama or LM Studio over an OpenAI-style URLRecommends Qwen3.6-35B-A3B and 32,768+ context
Ollama for VS CodeVS Code ChatOllamaAdds local models to the Chat model picker (VS Code 1.127+)
ContinueVS Code, JetBrainsOllamaStill 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
RuntimeBest forHow to set context
OllamaEasiest start; MLX engine on Macs, CUDA on NVIDIAApp slider, OLLAMA_CONTEXT_LENGTH, or the agent’s own setting
LM StudioGUI model browser; server on port 1234 with an Anthropic-compatible endpointlms load <model> --context-length=65536
llama.cppMost control; FIM presets for autocompletellama serve -hf ggml-org/Qwen3.8-27B-GGUF -c 65536
MLXApple silicon; LM Studio offers MLX builds such as Qwen3.8 27B 4-bitSet by the app that runs it
vLLM, SGLangNVIDIA servers shared by a team; Qwen recommends them for high throughputServer 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 GB

If 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
ModelStrong 27B open modelFrontier models (see our best AI for coding ranking)
Context64K typical, 128K with more memoryMuch larger, with prompt caching on the provider’s side
SpeedFine for MoE models; long prompts are slow to readDatacenter GPUs
Tool callsDepend on model and chat template; more misfiresModel and tool tuned together
Cost$0 after hardwareAbout $20 a month to start (pricing compared)
PrivacyCode never leaves your machineCode goes to the provider

The cheap hybrid setup

A practical middle ground costs a few dollars a month:

  1. Local autocomplete with llama.vscode or Zed: free, private and instant.
  2. Local agent for routine work: explaining code, writing tests, small edits.
  3. A paid model for the hard tasks: multi-file refactors, nasty bugs, anything that loops locally.

Three cheap ways to do step 3:

export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
export ANTHROPIC_AUTH_TOKEN=<your DeepSeek API key>
export ANTHROPIC_MODEL=deepseek-flash[1m]
claude

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.

Need AI agents that run on your own hardware?

stackcone builds private agents on open-weight models: deployed on your machines or servers, wired into your tools, and tested so you know what they can and can’t do.