From 78fcb1d7aabde77ad1f9764bed421febe5620a42 Mon Sep 17 00:00:00 2001 From: Oliver Sanctus Georgius Date: Thu, 18 Jun 2026 00:10:53 -0300 Subject: [PATCH] fix: read reasoning_content as fallback for empty content in generate Some models (e.g. GLM-4.5-flash with /no_think) return content as empty string and put the actual response in reasoning_content field. This patch reads reasoning_content as fallback when content is empty. --- src/llm.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/llm.ts b/src/llm.ts index 21b74dd..54a86b5 100644 --- a/src/llm.ts +++ b/src/llm.ts @@ -1049,12 +1049,15 @@ export class LlamaCpp implements LLM { } const data = await resp.json() as { - choices: { message: { content: string } }[]; + choices: { message: { content?: string; reasoning_content?: string } }[]; model?: string; }; + const msg = data.choices[0]?.message; + const text = msg?.content || msg?.reasoning_content || ""; + return { - text: data.choices[0]?.message?.content || "", + text, model: data.model || this.remoteLlmUrl!, done: true, };