From 69cce6498553376bc3722b3d8e3452f63922faf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E5=A4=A9?= Date: Thu, 14 May 2026 02:30:53 +0800 Subject: [PATCH] fix(hermes-model-switch): clear stale 'context_length' when switching model in config.yaml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the user switches model via the model picker, hermes_update_model rewrites model.default and model.provider in config.yaml but historically left model.context_length untouched. The Hermes kernel (8ac351407, May 2026) now actively clears that field on model switch because the previous model's context window almost never matches the new model — leaving the stale value caused 'context too large' errors and silently truncated output. Mirror the upstream behavior by dropping the context_length line as we walk the model: block, so Hermes falls back to the new model's default window. --- src-tauri/src/commands/hermes.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src-tauri/src/commands/hermes.rs b/src-tauri/src/commands/hermes.rs index afe08aa..9980ace 100644 --- a/src-tauri/src/commands/hermes.rs +++ b/src-tauri/src/commands/hermes.rs @@ -2278,6 +2278,12 @@ pub async fn hermes_update_model( provider_written = true; continue; } + // 与 Hermes 内核 8ac351407 保持一致:切模型时清掉旧 context_length, + // 否则新模型会沿用上一个模型的 context window(典型表现:context 报错 + // / 输出被截断)。删除该行即可,Hermes 会按新模型默认窗口生效。 + if trimmed.starts_with("context_length:") { + continue; + } } out.push(line.to_string()); }