Portrait of Michael Limberger

Michael Limberger

Need me? Email mike@limberger.ca

AI

Context Windows - Critical Setup

Four thousand tokens is a trap

This part is not optional. If you skip it, Claude Code will barely function. Ollama's default makes coding tools nearly useless. You have to fix it.

qwen3-coder-next supports 256,000 tokens. Ollama's default is 4,096. That is 1.6% of the model's capability, like buying a sports car and driving it in first gear. With 4K, the system prompt eats about 1,000 tokens, CLAUDE.md about 500, and one medium file eats the rest. There is no room for history. The model "forgets" what you just said, ignores files, gives incomplete answers, and says it does not have access to a file that was truncated out of context.

Ollama uses 4K because it works on any hardware, uses minimal RAM, and prevents out-of-memory crashes. For coding tools, 4K is worthless. You must increase it.

Bake the window into the model

Show me. Write a Modelfile, create the model, then point settings.json at the new name:

FROM qwen3-coder-next:latest
PARAMETER num_ctx 32768
ollama create qwen3-coder-32k -f ~/Modelfile-qwen-claude

Claude Code talks to Ollama via /v1/messages, which is Anthropic's API format. That API has no num_ctx field. Context is server-side. Ollama uses whatever default the model has. Base model: 4K. Custom model: 32K. The Modelfile is the only reliable way to control this.

How much window you can afford

ContextExtra RAMGood for
8K tokens~2GBLight use, small files
16K tokens~4GBNormal coding sessions
32K tokens~8GBMultiple files, longer chats
64K tokens~16GBLarge codebases
128K tokens~32GBMassive context needs

That is on top of the model weights (about 20GB for qwen3-coder-next). On 16GB unified memory, stay near 8K. On 32GB, use 16K to 32K. On 64GB, use 32K to 64K. On 96GB, 64K+ is realistic.

You can keep several: 8k for light and fast, 32k as the standard, 64k for heavy work. Switch the name in settings.json. Verify with ollama run qwen3-coder-32k, then ollama ps. CONTEXT should show 32768.

When the window fills

Truncation means old messages drop. The model forgets what you discussed 30 minutes ago. Symptoms: repeating questions, forgetting files it already read, losing the task, contradicting itself. Claude Code tracks token usage and may summarize. There is no magic. Eventually things get lost.

Inside Claude Code, /context shows usage percentage, what is loaded, and warnings. /compact summarizes and clears old messages. You lose detail and free space. Do it after a major task, when /context shows 70%+, or before a new topic. Do not wait until it breaks.

Auto-compact in settings.json: set CLAUDE_AUTOCOMPACT_PCT_OVERRIDE to "75". Instruction-following actually degrades with very large contexts. Important information gets diluted. At 128K, CLAUDE.md can sit far from the current message. Sweet spot for most coding: 16K to 32K. Only go higher if you genuinely need massive files in one session.

A new topic means a new session. Hit Ctrl+D, then run claude. You get a full context and a clean slate. Do not try to do everything in one conversation.