From c00214e4086ae9f7db33ec3045537f2142885dbb Mon Sep 17 00:00:00 2001 From: prosolis <5590409+prosolis@users.noreply.github.com> Date: Sat, 14 Mar 2026 12:17:36 -0700 Subject: [PATCH] Strip Qwen 3.5 thinking tags from Ollama responses Co-Authored-By: Claude Opus 4.6 --- internal/plugin/howami.go | 10 +++++++++- internal/plugin/llm_passive.go | 8 ++++++++ internal/plugin/wotd.go | 9 ++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/internal/plugin/howami.go b/internal/plugin/howami.go index f478a57..c67ea63 100644 --- a/internal/plugin/howami.go +++ b/internal/plugin/howami.go @@ -218,5 +218,13 @@ func callOllama(host, model, prompt string) (string, error) { return "", fmt.Errorf("parse response: %w", err) } - return strings.TrimSpace(result.Response), nil + response := result.Response + // Strip ... blocks (Qwen 3.5 reasoning) + if i := strings.Index(response, ""); i != -1 { + if j := strings.Index(response, ""); j != -1 { + response = response[:i] + response[j+len(""):] + } + } + + return strings.TrimSpace(response), nil } diff --git a/internal/plugin/llm_passive.go b/internal/plugin/llm_passive.go index 60c8d2b..5a9fc7e 100644 --- a/internal/plugin/llm_passive.go +++ b/internal/plugin/llm_passive.go @@ -548,6 +548,14 @@ Message: %s`, messageText) func parseClassification(raw string) (*classificationResult, error) { cleaned := raw + // Remove ... blocks (Qwen 3.5 reasoning) + if i := strings.Index(cleaned, ""); i != -1 { + if j := strings.Index(cleaned, ""); j != -1 { + cleaned = cleaned[:i] + cleaned[j+len(""):] + cleaned = strings.TrimSpace(cleaned) + } + } + // Remove markdown code fences cleaned = strings.TrimSpace(cleaned) if strings.HasPrefix(cleaned, "```json") { diff --git a/internal/plugin/wotd.go b/internal/plugin/wotd.go index e284d7c..f57f40b 100644 --- a/internal/plugin/wotd.go +++ b/internal/plugin/wotd.go @@ -347,7 +347,14 @@ Respond with ONLY "yes" or "no".`, message, word) return false } - answer := strings.ToLower(strings.TrimSpace(result.Response)) + response := result.Response + // Strip ... blocks (Qwen 3.5 reasoning) + if i := strings.Index(response, ""); i != -1 { + if j := strings.Index(response, ""); j != -1 { + response = response[:i] + response[j+len(""):] + } + } + answer := strings.ToLower(strings.TrimSpace(response)) accepted := strings.HasPrefix(answer, "yes") slog.Debug("wotd: LLM verification", "word", word, "answer", answer, "accepted", accepted) return accepted