fix(harness): 将记忆刷写与压缩流程切到阻塞线程池#1612
Open
guslegend0510 wants to merge 6 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
AgentScopeJavaBot
approved these changes
Jun 5, 2026
AgentScopeJavaBot
left a comment
Collaborator
There was a problem hiding this comment.
🤖 AI Review
This PR addresses a reactive anti-pattern where blocking filesystem I/O (workspace file reads/writes in MemoryFlushManager and ConversationCompactor) was executing on Reactor's non-blocking scheduler threads. The fix correctly offloads these blocking operations to Schedulers.boundedElastic() using the standard Reactor patterns. Additionally, a bug in ToolCallParam.Builder's copy constructor is fixed. Both new test classes directly assert that blocking I/O does not run on non-blocking threads via Schedulers.isInNonBlockingThread().
Member
Contributor
Author
|
@LearningGp , |
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.


描述
背景
PR #1480 的核心目标是避免在 Reactor 非阻塞线程上执行记忆刷写、压缩和卸载这类阻塞操作。由于旧的 autocontext 模块已经不在主线上,这次把修复迁移到了当前 agentscope-harness 的 memory pipeline。
主要改动
MemoryFlushManager.flushMemories() 拆分了输入构造、模型流式处理和文件写入步骤。
将涉及文件 IO / 模型流处理的逻辑切到 Schedulers.boundedElastic(),避免阻塞调用占用非阻塞线程。
ConversationCompactor.compactIfNeeded() 改为延迟执行,并切到 boundedElastic。
offload 路径解析等阻塞步骤也显式切换到 boundedElastic。
新增回归测试,覆盖 non-blocking scheduler 场景下的线程切换行为。
验证
mvn -pl agentscope-harness "-Dtest=ConversationCompactorTest,MemoryFlushManagerTest" test