llama-server: the request exceeds the available context size, try increasing it (request longer than the context length)
The llama.cpp server rejects your request with HTTP 400 because the prompt, chat history, and tool descriptions together contain more tokens than the configured context length allows. This is typical with coding assistants and agents that always send the full history along.
The message
srv send_error: task id = 21, error: the request exceeds the available context size, try increasing it
Affects: llama.cpp
Why is this happening?
When it starts, llama-server reserves a fixed context (-c / --ctx-size). If the request is longer, newer versions no longer trim it automatically; they reject it instead. According to the developer, the program sending the request should do the trimming. Also, the context length is split across the parallel slots (--parallel), so each slot only gets part of it.
How to fix it
- Check the log to see how large the request and context are: the line
new prompt, n_ctx_slot = …, task.n_tokens = …shows the space per slot and the length of your request. - Start llama-server with a larger context length, for example
-c 32768. The value must not be higher than what the model was trained for, and it needs more VRAM. - If you use multiple slots with
--parallel,-cis divided by the number of slots. Lower--parallelor raise the context length accordingly. - Enable automatic trimming or summarizing of the history (Context Compaction) in your chat or coding program, or start a new chat.
Better not: Don't raise -c beyond the model's training length just to get rid of the message: that can cause crashes (GGML_ASSERT) or poor answers.
Set up from scratch again
If it still doesn’t work after that, a fresh setup step by step often helps:
- LM Studio: Your First Local Chat
Install LM Studio on Windows, load a suitable language model, and chat offline, even with your own documents.
Terms for this
Similar errors
- Model forgets the beginning or ignores long texts (context length too small)
- Confusing answers, endless loops, or tags like <|im_end|> (wrong chat template)
- GGUF: tensor '…' data is not within the file bounds, model is corrupted or incomplete (model file incomplete)
- GGUF: unknown model architecture (program too old for the model)
- llama.cpp: CUDA error: out of memory
Sources
- https://github.com/ggml-org/llama.cpp/issues/17284
- https://github.com/ggml-org/llama.cpp/issues/11681
Checked on Oct 28, 2026. Didn't help? Ask in the forum and name the graphics card, program, and the full message.