From 7ef6d1d17add9ec3df7dac6a88cc556d6fdd1ab3 Mon Sep 17 00:00:00 2001 From: QuXiangyu <771744189@qq.com> Date: Wed, 8 Apr 2026 16:52:37 +0800 Subject: [PATCH] fix(agent): correct soft-trim head/tail budget allocation when tail is important (#723) Co-authored-by: quxy5 --- internal/agent/pruning.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/agent/pruning.go b/internal/agent/pruning.go index 7a5025ec..9d19deea 100644 --- a/internal/agent/pruning.go +++ b/internal/agent/pruning.go @@ -205,8 +205,8 @@ func pruneContextMessages(msgs []providers.Message, contextWindowTokens int, cfg tailChars := settings.softTrimTailChars if hasImportantTail(msg.Content) { totalBudget := headChars + tailChars - headChars = totalBudget * 7 / 10 - tailChars = totalBudget - headChars + tailChars = totalBudget * 7 / 10 + headChars = totalBudget - tailChars } head := takeHead(msg.Content, headChars) tail := takeTail(msg.Content, tailChars)