Repository navigation
fix(harness): return lightweight pruning result when safe cutoff is zero - #3571
Merged
jujn merged 5 commits intoOct 18, 2026
Merged
Conversation
- compactStandard 在 determineCutoffIndex 得到 cutoff<=0 时直接返回 Optional.empty(),把已完成的 prune/truncate 轻量结果一并丢弃,导致 "触发压缩但无可摘要前缀" 场景下上下文体积没有任何下降。 - 改为与轻量分支一致:仅当 messages 与原列表不同才返回 Optional.of(messages), 否则维持 Optional.empty(),不改变可摘要场景的原有行为。 - 回归:ConversationCompactorTest 新增 cutoff=0 返回轻量结果、以及无变化仍返回 空的用例;修复前第一个用例断言失败(结果被丢弃)。 只调整 cutoff<=0 分支的返回值,不改 trigger/keep/prune/truncate 算法。
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…eight-result-return
…return' into fix/compaction-lightweight-result-return
jujn
force-pushed
the
fix/compaction-lightweight-result-return
branch
from
October 18, 2026 12:37
0b1817d to
593366c
Compare
jujn
approved these changes
Oct 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AgentScope-Java Version
2.1.0-SNAPSHOT (based on
main@ 5f7f8e6)Description
Fixes #2970.
Background
ConversationCompactor.compactStandardperforms lightweight, non-LLM pruning (argument truncation + tool-result pruning) before deciding whether to summarize. When pruning changes the conversation but the safe cutoff point ends up at 0 (nothing summarizable ahead), the method returnsOptional.empty().CompactionMiddlewarethen keeps the originalReasoningInputand skips the state update, so the next model request still carries the oversized content and can overflow again.The other early-return branch (pruned below the trigger threshold) already returns the pruned messages; this PR aligns the
cutoff <= 0branch with that behavior.Note: #2971 proposed a fix for the same issue but has been stalled; this is a minimal, rebased version of that idea.
Changes
ConversationCompactor: whencutoff <= 0, return the pruned messages when they differ from the input (Optional.of(messages)); keepOptional.empty()when pruning changed nothing.Tests
ConversationCompactorTest8 → 10:compactIfNeeded_returnsLightweightResultWhenCutoffIsZero,compactIfNeeded_keepsEmptyWhenCutoffZeroAndNothingChanged; suite 10/10 green.mvn spotless:checkpasses.Checklist
mvn spotless:applymvn test)