Ollama Context Limits: Keep Instructions, Evidence and Output in Budget
An advertised model context window is not proof that a particular Ollama process allocated that window. Runtime configuration, available memory and client settings also matter. Oversized requests may error or lose input depending on the path and configuration; test what the application actually receives.
The budget includes instructions, conversation, retrieved evidence, tool definitions and generated output. A short visible question can sit inside a large hidden application prompt.
Inspect the effective request
Record the exact model tag, runtime version, requested context and generated-output limit. Inspect ollama ps or /api/ps after the model is loaded; the API exposes its allocated context length. Compare that with the model’s documented supported context, not another variant’s limit.
Do not rely on one universal default. Ollama’s context documentation describes defaults that depend on available VRAM, and clients can request different settings.
An illustrative request, with the model placeholder replaced, is:
curl --fail-with-body http://127.0.0.1:11434/api/chat \
-H 'Content-Type: application/json' \
-d '{"model":"MODEL_NAME","messages":[{"role":"user","content":"Reply briefly."}],"options":{"num_ctx":4096,"num_predict":256},"stream":false}'
These are example limits, not a promise that every model/runtime combination accepts them or that the full application prompt fits.
Reduce input without deleting the contract
| Excess input | Safer reduction |
|---|---|
| Entire chat history | Deliberate summary plus retained constraints |
| Large retrieved documents | Relevant passages with source IDs |
| Repository-wide context | Files needed for the specific edit |
| Repeated tool output | Bounded results and structured summaries |
| Large tool catalog | Only tools required for this workflow |
Token counts depend on the tokenizer. A fixed “four characters per token” truncation is not a safe enforcement mechanism. Preserve system instructions, authorization boundaries and the evidence needed to answer; otherwise a smaller prompt can become a different, unsafe task.
Increase context only with an acceptance test
A larger context consumes more memory and can increase prefill time. Check memory pressure and prompt-processing latency before raising it.
For local RAG, test questions whose answer lies near the end of the supplied evidence and cases where the answer is absent. For Aider, check that required files and repository constraints survived context construction.
Stop when the effective context is known, required information survives, the output budget is sufficient and the workload remains stable. An accepted request alone does not establish long-context quality.
Sources checked November 10, 2026: context configuration, running-model API, chat options. Browse the local inference hub for related operating decisions.