fix(hermes-model-switch): clear stale 'context_length' when switching model in config.yaml

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.
This commit is contained in:
晴天
2026-05-14 02:30:53 +08:00
parent 65e9a4c90c
commit 69cce64985

View File

@@ -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());
}