Skip to content

refactor(autocontext): expose async compression entry & remove redundant subscribeOn#1480

Open
guslegend0510 wants to merge 5 commits into
agentscope-ai:mainfrom
guslegend0510:fix/issue-1447
Open

refactor(autocontext): expose async compression entry & remove redundant subscribeOn#1480
guslegend0510 wants to merge 5 commits into
agentscope-ai:mainfrom
guslegend0510:fix/issue-1447

Conversation

@guslegend0510

Copy link
Copy Markdown
Contributor

说明

修复 AutoContextMemory 在 WebFlux/reactive 执行链路中可能触发 .block() 阻塞 event-loop 的问题。

变更

  • compressIfNeededAsync() 暴露为 public,作为 reactive 场景的推荐入口
  • AutoContextHook 直接调用异步压缩入口,避免额外调度干预
  • 增加回归测试,验证可从非阻塞调度器正常调用异步压缩

测试

  • mvn -s codex-maven-settings.xml -pl agentscope-extensions/agentscope-extensions-autocontext-memory -am "-Dtest=AutoContextMemoryTest,AutoContextHookTest" test

关联

@guslegend0510 guslegend0510 requested a review from a team May 24, 2026 04:29
@CLAassistant

CLAassistant commented May 24, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecov Bot commented May 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@AgentScopeJavaBot AgentScopeJavaBot added bug Something isn't working area/ext/memory Memory/session extension implementations labels May 28, 2026

@LearningGp LearningGp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LearningGp LearningGp changed the title 修复:AutoContextMemory 在 WebFlux/reactive 场景下的阻塞问题 refactor(autocontext): expose async compression entry & remove redundant subscribeOn Jun 4, 2026
@LearningGp

Copy link
Copy Markdown
Member
image

@AgentScopeJavaBot AgentScopeJavaBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review

This PR refactors the scheduler offloading logic in the autocontext memory module. It removes redundant subscribeOn(Schedulers.boundedElastic()) from AutoContextHook.handlePreReasoning() and promotes compressIfNeededAsync() from package-private to public as the preferred entry point for reactive callers. The old data-driven async test is replaced with a thread-verification test. No unintended behavioral changes.

}
}

private static final class RecordingAutoContextMemory extends AutoContextMemory {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] RecordingAutoContextMemory is defined identically in both AutoContextHookTest and AutoContextMemoryTest. Consider extracting it to a shared test utility class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ext/memory Memory/session extension implementations bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]:AutoContextMemory calls block() during WebFlux reactive execution

5 participants