Repository navigation
Conversation
- CompactionMiddleware 内部自建 MemoryFlushManager 并在压缩前无条件 flush, 绕过了 HarnessAgent.disableMemoryHooks():记忆已关闭仍写长期记忆,并额外 发起一次抽取 LLM 调用。 - CompactionMiddleware 新增 memoryHooksEnabled 开关(3 参构造保持 true 兼容), 关闭时对生效配置调用 withoutMemoryFlush(),压缩前置 flush 直接跳过; overflowRecovery 内部重建的强制实例同样透传该开关。 - CompactionConfig 抽出 copyBuilder 并新增 withoutMemoryFlush()。 - HarnessAgent 构造 compactionHook 时传入 !disableMemoryHooks。 - 回归:CompactionMiddlewareTest 覆盖关闭时跳过 flush、开启时仍 flush;修复前 关闭用例断言失败(flush 仍发生)。 只调整压缩期记忆 flush 的开关,不改 trigger/keep/summary 算法。
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
dargoner
force-pushed
the
fix/memory-hooks-compaction-flush
branch
from
October 18, 2026 13:13
14c7407 to
d4e1083
Compare
This branch has not been deployed
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 #2694.
Background
disableMemoryHooks()already disables per-call memory flush and background consolidation, but normal compaction could still flush long-term memory from the summarized prefix — spending an extra model call and writing memory for an agent that explicitly opted out of memory hooks.Note: #2699 addressed the same issue but has been stalled with merge conflicts; this is a minimal, rebased version scoped to the compaction path.
Changes
CompactionMiddleware: newmemoryHooksEnabledflag (4-arg constructor; the existing 3-arg constructor keeps the current behavior of flushing). When disabled, the effective config for the normal path drops the pre-compaction flush, and the emergency (forced) middleware receives the same flag.CompactionConfig:withoutMemoryFlush()returns a copy withflushBeforeCompact=false(small sharedcopyBuilder()refactor withwithEffective).HarnessAgent: passes!disableMemoryHookswhen wiring the compaction middleware.Summarization and session JSONL offload are unaffected; directly constructed
CompactionMiddlewareinstances keep flushing.Tests
CompactionMiddlewareTest11 → 13:disabledMemoryHooksSkipCompactionTimeFlush,enabledMemoryHooksStillFlushDuringCompaction; suite 13/13.HarnessAgentTest55/55 (integration wiring unchanged).mvn spotless:checkpasses.Checklist
mvn spotless:applymvn test)