Skip to content

Kingy / AI Fix Finder

← All fixes

Request exceeds the available context size: how to fix Ollama

Check this fix ↓

Ollama returned HTTP 400 because the 518-token rendered request exceeded its 512-token allocation. This retained build rejected the input; it did not silently truncate it.

kingy tested

Fix

  1. Keep the failed request and error. Check the actual loaded context, including template, history and output room.
  2. Increase options.num_ctx within the model and memory limits, then confirm the loaded allocation. The retained case changed 512 to 2048.
  3. Repeat the unchanged task and verify every required fact; 2048 is a tested case setting, not a universal minimum.

Tested repair · Ollama · Ollama 0.40.5; CPU runner

Check this fix

Applies when
Ollama returned HTTP 400 because the 518-token rendered request exceeded its 512-token allocation. This retained build rejected the input; it did not silently truncate it.
Change to inspect
Increase the effective options.num_ctx for the same local model and request, within its supported context and available memory. This retained correction changed 512 to 2048; loaded-state readback confirmed 2048.
Expected result
0/3 baseline task passes; 3/3 corrected exact-task passes; 0/1 reverted task passes. The corrected cohort is shared with the other repair for this runtime.
If it still fails
Keep the original failed output and check the conditions and verification steps below. Retained failed attempt: The unchanged 518-token request was rejected at a loaded 512-token context.

Tested or reviewed 2026-10-17. Verify the original task on your own version and settings; this case does not prove a universal fix.

Read the verification steps ↓ · Report your outcome ↓

What happened

Symptom

Ollama returned HTTP 400 because the 518-token rendered request exceeded its 512-token allocation. This retained build rejected the input; it did not silently truncate it.

Exact environment and tested conditions

Ollama 0.40.5; CPU runner; same pinned Qwen3-4B Q4_K_M weights.

Loopback-only API, full unchanged synthetic source, temperature 0, reasoning disabled, one model/slot, 128-token output cap.

Model-file SHA-256 7485fe6f11af29433bc51cab58009521f205840f5b4ae3a32fa7f92e8534fdf5.

Correction

Increase the effective options.num_ctx for the same local model and request, within its supported context and available memory. This retained correction changed 512 to 2048; loaded-state readback confirmed 2048.

Result

0/3 baseline task passes; 3/3 corrected exact-task passes; 0/1 reverted task passes. The corrected cohort is shared with the other repair for this runtime.

What did not work

The unchanged 518-token request was rejected at a loaded 512-token context.

  1. Increase the effective options.num_ctx for the same local model and request, within its supported context and available memory. This retained correction changed 512 to 2048; loaded-state readback confirmed 2048.
  2. Preserve the full original input and enough output room, then verify every required fact. Here, 2048 was a tested setting for one 518-token synthetic request, not a universal minimum or a memory-fit promise.
  3. Inspect the retained request, loaded context and raw response before applying the correction to your own setup.
Sources & limits

Full Ollama request exceeds the available context size qualification report and limits

Download Ollama and LM Studio evidence ZIP (52,216 bytes; SHA-256 65272c0b665b287961907c19cb085473797ef83706a8ba754373b1847fecfb3b)

Record checked 2026-10-17.

Same agent, one Apple M4 Pro Mac with 24 GiB unified RAM, one Qwen3-4B Q4_K_M artifact. No independent human or second-machine reproduction.

Three baseline failures, three corrected exact-task passes and one reverted failure per repair. The two repairs for each runtime share the identical three corrected attempts; these are six unique corrected generations total, not twelve.

Fixed synthetic task, not a reliability estimate or proof for other models, versions or hardware. No real OOM condition was induced. No Ollama or LM Studio memory-fit calibration is claimed.

Existing weights were reused, with no model download or paid inference. A free official Ollama portable runtime was added; runtime binaries and weights are excluded from the evidence ZIP.

CPU-only, num_gpu=0, one parallel request, four threads. Corrected responses reported done=true and done_reason=stop, with output below the 128-token cap.

The early lookup probes omitted an explicit thread setting and are exploratory. The qualified lookup baseline was repeated with the final fixed options, including num_thread=4.

This still happens?

Send the smallest example that reproduces it. Use a public, non-sensitive example; leave out account details, keys and private files.

Help improve this tool

Did this repair work for you?

About AI Fix Finder. Your self-reported outcome goes to Kingy’s private review queue; it is not an independently verified reproduction.

Your experience with AI Fix Finder
What happened?

All free tools · Local Lab evidence · Check tool changes

Saved settings stay on this device. Shared links omit private text and actual spending. Reports enter a private review queue. No generated claims or automatic publication.

Contribute a reproducible result

Include the outcome, exact versions, prompts and settings, every attempt, failures, charges if recorded and active repair time. Supply files you own or have permission to share, an attribution and a public evidence link. Remove personal data, tokens and private prompts. Reports are reviewed before any public use; submitting does not publish your work.

Prepare a reproducibility report

Ollama returns normally but silently truncates a long prompt

Kingy-tested setup observation, November 15–16, 2026: input preservation confirmed; task still failed. This is a separate variant from the Ollama 0.40.5 HTTP 400 rejection above. On Ollama 0.40.16 with qwen3:4b (digest prefix 359d7dd4bcda), a long API request returned a response without an API error while the server logged input truncation.

truncating input prompt limit=2050 prompt=6026 keep=4 new=2050
prompt_eval_count=2050

The runtime selected a 4,096-token default context. The rendered prompt contained 6,026 tokens, but the reported evaluated prompt count was only 2,050. A normal response alone did not establish that the complete input reached the model.

Increase the request context, then check what was actually read

  1. Keep the original input and inspect the server log plus prompt_eval_count. If the log reports truncation, preserve that failed result.
  2. For the local Ollama API, request a context allocation that can hold the full input and output allowance, within the model's limits and available memory. The retained rerun used "options": {"num_ctx": 16384, "num_predict": 400}. A larger context needs more memory; this is a tested setting for this run, not a universal minimum.
  3. Check ollama ps for the loaded allocation. Here it showed a 16,384-token context and 5.1 GB. The rerun reported prompt_eval_count=6026; no new truncation warning was recorded.
  4. Verify the answer against the original task as well as the input count. The retained word-count task still failed: the output repeated source text and ended with done_reason=length after 400 generated tokens. Preserving the input did not repair that answer.

The rerun also increased the output allowance from 30 to 400, so it is not a one-setting task-success comparison. An interactive /set parameter num_ctx 8192 was accepted separately; the same long prompt was not rerun at that setting.

These observations come from one M4 Pro Mac with 24 GB unified memory, macOS 26.3 and one model. They do not establish reliability on other models or versions. The original October 17 rejection test, its corrected task passes and its measurement date remain unchanged above.

Read the official Ollama context-length guidance and the tested Ollama setup walkthrough. The private setup logs are summarized here without publishing local paths.

Open WebUI makes a short Ollama question exceed the context

Kingy-tested setup observation, November 16, 2026: truncation reproduced and removed for this question. This is an Open WebUI 0.13.3 variant of the silent-truncation problem above, using Ollama 0.40.16 and qwen3:4b on one M4 Pro Mac with 24 GB unified memory. A 17-word question reached Ollama as a 5,642-token prompt. The response returned without an error, but Ollama's log and the answer's usage showed that most of the prompt was cut:

truncating input prompt limit=2050 prompt=5642 keep=4 new=2050
prompt_eval_count=2050

Our model had twelve Open WebUI built-in tools switched on. With native tool calling, their schemas entered the prompt. Ollama selected a 4,096-token context on this Mac and evaluated only 2,050 tokens. The same question was cut in two chats. A short question in the text box did not mean a short request reached the model.

Fix the prompt and verify the original question

  1. If you do not need the built-in tools: in Open WebUI's Admin Panel, open Settings > Models, edit the affected model, and switch off Capabilities > Builtin Tools. With our 8,192-token context still set, the same question then used a 30-token prompt. We did not separately rerun this tools-off setting at the 4,096-token default.
  2. If you need the tools: leave them on and give the model enough context. In the model's Advanced Params, our tested num_ctx (Ollama): 8192 setting processed all 5,642 prompt tokens without a new truncation warning. The three answer attempts took 38–48 seconds. Check available memory: ollama ps showed 3.8 GB at 8,192, compared with 3.2 GB we had observed at 4,096. Open WebUI's context control pre-fills 2048 when changed from Default to Custom, so enter the intended value before saving.
  3. Check the result: repeat your original question, inspect Ollama's truncating input prompt warning and prompt_eval_count, and confirm the answer uses the information you supplied. A returned answer or a larger context setting alone does not prove the full task succeeded.

Slow answers are a separate symptom. With background generation enabled, the answer queued behind another request in six of seven tries, adding about 15–23 seconds of wait. Switching off Builtin Tools shortened prompt reading, but the observed answer times still ranged from 8.6 to 29 seconds because request order varied. Turning off Title Generation, Follow Up Generation, Tags Generation and Retrieval Query Generation under Admin Panel > Settings > Interface left one answer request, which took 12.3 seconds in one try. That single run is not a speed guarantee; disabling those jobs also removes their automatic outputs.

Applicability and limits: these are cumulative settings from one Open WebUI/Ollama/model/Mac setup, not independent reliability estimates. The Mac was under heavy memory pressure during the timing checks; swap use rose from about 15 to 21 GB. The 8,192 setting was tested with tools on; the 30-token result was tested with tools off and 8,192 still set. Open WebUI also documents setting OLLAMA_CONTEXT_LENGTH on the Ollama server while leaving its own num_ctx unset; we did not test that route. We did not test Tool Search, a separate task model or another local model. No raw account screenshot or local log path is published here.

Read the official Open WebUI Ollama context guidance, its built-in tool explanation, and our tested Open WebUI setup walkthrough.