request (4390 tokens) exceeds the available context size (4096 tokens), try increasing it
The message
request (4390 tokens) exceeds the available context size (4096 tokens), try increasing itWhat it means
The prompt your app sent is longer than the context llama-server has for one request, so it refused it without generating anything. The first number is your prompt in tokens, the second is the limit.
What to do
Start llama-server with a bigger -c (--ctx-size) if you have the memory, or trim the conversation on the client side. The server won't shorten it for you.
llama-server, the HTTP server that ships with llama.cpp, sends this back as an HTTP 400 when a prompt is too long. This body is copied from #19774:
{"error":{"code":400,"message":"request (4390 tokens) exceeds the available context size (4096 tokens), try increasing it","type":"exceed_context_size_error","n_prompt_tokens":4390,"n_ctx":4096}}
The server log has the same text on a srv send_error: line. Your client may only show the message field, or a generic "400 Bad Request" from whatever sits in front of the server. We read the server code in release v0.5.0 (September 23, 2026): once the prompt is tokenized, if it has as many tokens as the request's context or more, the server rejects it and generates nothing. n_prompt_tokens is your prompt and n_ctx is the limit it hit. Older builds (7062 in late 2025, for one) printed the request exceeds the available context size, try increasing it with no numbers.
Where the limit comes from
The context is the number of tokens the model can see at once, and you set it when you start the server with -c. Leaving it out, or passing -c 0, uses the length the model was trained on. A limit of 4096 on a model trained for far more usually means someone passed -c 4096 in a script or a launcher.
Parallel slots can cut it further. llama-server serves several requests at once, one per slot. With the default (-np left on auto), it runs four slots that share one cache and each can use the whole context. If you set -np 4 yourself, the shared cache is off unless you add --kv-unified, and each slot gets a quarter of -c. That's the number in the error.
Why it doesn't just cut the history
People expect it to drop old messages, especially with --context-shift set. That flag is for text generation that runs past the end of the context, and it doesn't touch an oversized prompt. In #17284 maintainer ggerganov wrote that "context truncation is the job of the client, not the server", and that the old auto-truncating logic "had various side-effects, so it was removed". That issue was closed as not planned in July 2026, and we found no truncation option in v0.5.0.
A different body, {"error":{"code":500,"message":"Context size has been exceeded.","type":"server_error"}}, comes from a later point, when the cache fills up while the model is running rather than at the prompt check. The reporter of #19774 got both from the same server.
What to do
- Restart with a bigger
-c, as the message says. The cache grows with it, so on a full GPU the server may then fail to start with "failed to create context". - If you set
-np, add--kv-unifiedor raise-cso each slot gets enough. - Trim on the client. A client that resends the whole conversation every turn (the Cline setup in #17284 did) grows into this limit. Turn on their compaction or history limit, and set their context size to the
n_ctxfrom the error so they know where the wall is.
Other lines the same feature prints
Match yours against these if the one at the top of the page is not quite it. They come from the same code and mean related things.
the request exceeds the available context size, try increasing itexceed_context_size_errorsrv send_error: task id = 18963, error: request (7655 tokens) exceeds the available context size (4096 tokens), try increasing itContext size has been exceeded.