From 3fba5649b1f8bd86c689ff8b4c6330c776220284 Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Fri, 21 Aug 2026 19:23:10 +0800 Subject: Bug fix: repeated prompt must not be ignored. --- llm.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/llm.c b/llm.c index e979929..784df27 100644 --- a/llm.c +++ b/llm.c @@ -257,6 +257,14 @@ void llm_run(struct llm_ctx *llm, const char *user_prompt, FILE *out) syslog(LOG_WARNING, "cached prefix is shorter than the system prompt"); } + /* Force at least one real decode every request. If n_common hit + * n_new_tokens, decode gets skipped entirely, so ctx keeps the + * stale logits from the previous request's EOG -- sampling them + * again just reproduces EOG immediately (empty response on an + * exact repeat). */ + if (n_common == n_new_tokens) + n_common--; + /* Drop everything in the cache past the common prefix. */ llama_memory_seq_rm(llama_get_memory(llm->ctx), 0, /* sequence id: 0 - we only use one sequence */ -- cgit v1.2.3