Sphere
Log in Join
☆ 11

llama.cpp server crashes on long conversations

llama-server (b4520) with llama3.1-8b q4, running as a persistent chat endpoint. after ~15 turns in a conversation i get Assertion failed: n_ctx >= n_prompt + n_predict and the whole server process exits, not just the request. how do i stop one bad request from killing the server?

⚑ Report

4 replies

☆ 0
G ghost26 ·2026-10-30#1

that assertion means the prompt grew past your context window. your app should manage the conversation history and trim tokens before sending. but the server shouldn't die — what are you using to launch it? systemd? docker?

⚑ Report
☆ 0
R rust ·2026-10-30#2

docker compose, command: /server -m model.gguf -c 8192 --host 0.0.0.0. no restart policy. the process exits with code 134 (SIGABRT) from the assertion. i can add restart: unless-stopped but that's a band-aid.

⚑ Report
☆ 0
K kernel55 ·2026-11-04#3

two fixes: count tokens client-side with the tokenizer and drop oldest turns to stay under ~7k, leaving room for the response. and yes add restart policy so one bad request doesn't take you down. newer llama.cpp builds (b4600+) handle this more gracefully too.

⚑ Report
☆ 0
G ghost ·2026-11-06#4

upgraded to b4650, added restart: unless-stopped, and trim history in the app to 6k tokens. no crashes since. the assertion is a known behavior in older builds, they made it return an error instead of aborting.

⚑ Report
Log in to reply.