AI Model Intelligence
Share
Local Deployment & Hardware

Ollama num_ctx Ignored? Check Client Context Overrides

Updated ยท Sources & corrections

In this guide
  1. Separate the three values you are checking
  2. Check the client before changing the server again
  3. Make one small direct request
  4. Interpret the comparison without jumping to a fix
  5. Verify the task, not only the allocation
  6. Sources and verification scope

Quick answer: If raising OLLAMA_CONTEXT_LENGTH appears to do nothing, check whether your application sends its own num_ctx. An explicit request setting can override the server default. Compare a small direct request with the frontend, inspect the running model on the same server, and change one setting at a time.

This guide is for local Ollama generation through its native API and clients such as Open WebUI. You need an already installed text model and access to the machine running Ollama. It does not establish a model’s supported maximum or measure long-document accuracy.

Separate the three values you are checking

Context troubleshooting worksheet
ValueWhere to inspect itWhat it cannot prove
Configured defaultThe environment or settings of the running Ollama serverThat a client leaves that default unchanged
Requested contextThe request body or client parameter configurationThat the requested allocation was accepted
Running allocationollama ps on that server or its /api/ps responseThat every message or retrieved passage reached the model

The Ollama context guide documents hardware-dependent defaults and increased memory requirements for larger contexts. Avoid diagnosing an installation from a universal default copied from another version. Record your version and actual allocation instead.

Check the client before changing the server again

Open WebUI’s Ollama documentation identifies num_ctx in chat advanced parameters and model settings. When explicitly set, it is sent with requests and overrides OLLAMA_CONTEXT_LENGTH. Check both places; a saved preset can explain why changing only the server seems ineffective.

If you intend to inherit the server default, leave that override unset. If you intentionally need a per-chat value, keep it explicit and record it. Compare using a new, harmless chat so an old conversation or a different preset does not obscure the change. Do not assume these exact UI locations apply to every client or older release.

First confirm the client reaches the server you are inspecting. A container, remote connection or multiple backend nodes can make two apparently identical model names refer to different installations. Our frontend connection checks cover that prerequisite.

Make one small direct request

The following PowerShell example uses the native local API. Replace the placeholder with an installed model tag. The illustrative 8192 allocation and short output limit are diagnostic choices, not recommendations for every model or GPU. Check the model’s documentation and available memory first.

$modelTag = 'REPLACE_WITH_INSTALLED_MODEL_TAG'
$requestBody = @{
    model = $modelTag
    prompt = 'Reply with the word ready.'
    stream = $false
    options = @{ num_ctx = 8192; num_predict = 32 }
} | ConvertTo-Json -Depth 5

# Inspect the exact body before sending it.
$requestBody
$reply = Invoke-RestMethod -Method Post `
    -Uri 'http://localhost:11434/api/generate' `
    -ContentType 'application/json' -Body $requestBody
$reply | Select-Object model, done, done_reason, prompt_eval_count, eval_count

# Inspect the same server immediately after the request.
(Invoke-RestMethod -Uri 'http://localhost:11434/api/ps').models |
    Select-Object name, context_length, size_vram

The official FAQ shows per-request options.num_ctx. The parameter reference distinguishes that context setting from num_predict, the generation-token limit. Increasing the latter does not enlarge the context window.

The generation response includes completion and token-count fields; stream: false makes this example a single JSON response. A thinking-capable model may use its generation budget differently, so the short request is not an answer-quality test. For streamed responses, use our stream parsing guide.

The running-model endpoint exposes context_length. Match its model name to the request. It is a runtime snapshot, not a request audit trail: another client may run before you inspect it, or the model may already have unloaded. Stop competing test requests where practical. An empty list does not prove the preceding generation failed.

Interpret the comparison without jumping to a fix

Choose the next diagnostic step
ObservationNext step
Direct request has the intended allocation, frontend does notCompare frontend model/chat overrides and backend addresses; repeat with one client.
Neither path has the intended allocationConfirm model tag, server version, request options and the running server’s configuration. Save any API error instead of treating it as success.
Allocation is correct, but earlier information disappearsInspect whether the frontend summarizes, drops messages or limits retrieved passages before sending them. Compare the actual payload using non-sensitive test text.
Larger context causes loading failures or slower workReturn to the prior working value and compare memory placement and timings. Change one variable rather than increasing all limits.

For a server-default change, configure the process that actually runs Ollama. Setting an environment variable in a separate terminal does not update an already running service. Follow the FAQ’s instructions for your operating system and restart that server through its normal app or service mechanism. Recheck the direct request and client afterward.

A model being fully on the GPU is a placement observation, not a guarantee of speed. Keep prompt and model constant when comparing settings. If the delay happens mainly after an idle gap, our reload-delay guide separates loading from generation work.

Verify the task, not only the allocation

After settings agree, use a small document with facts you can check at the beginning, middle and end. Ask separate questions about those facts and inspect both the submitted content and answers. This is an application check, not a model benchmark. A correct answer to one question does not prove that every token was retained or that a longer document will work.

Save a short comparison record: client and server versions, backend address, exact model tag, request options, running allocation, observed errors and the settings you restored. Avoid putting private conversation content into diagnostic logs.

Sources and verification scope

Reviewed against the linked official Ollama and Open WebUI documentation on 23 October 2026. The PowerShell example was syntax-checked and its constructed request body validated locally; it was not sent to a live Ollama model. No performance or long-context retention result is claimed. The featured image is an original generated illustration. See our sourcing and correction policy.