Skip to main content
agentscope-extensions-memory-bailian integrates with Alibaba Cloud Bailian’s long-term memory service. It is fully managed and supports advanced retrieval features such as rerank, judge, and rewrite.

When to use

  • You are already on Alibaba Cloud Bailian and want to reuse memory libraries from the platform.
  • You care about retrieval quality and want to use Bailian’s rerank / judge / rewrite pipeline.
  • You need three-level isolation via userId + memoryLibraryId + projectId.

Add the dependency

Quickstart

BailianLongTermMemory implements AutoCloseable — try-with-resources is recommended so the underlying HTTP connections get released.

Retrieval feature switches

On top of basic recall, Bailian supports three pipeline switches:
Leave them off by default unless you need them — they add latency and cost.

Message filtering

Bailian memory only stores natural user/assistant exchanges:
  • Only MsgRole.USER and MsgRole.ASSISTANT messages are written.
  • Assistant messages containing ToolUseBlock (tool-call requests) are skipped.
  • Messages with the <compressed_history> marker are skipped to avoid storing duplicated compressed history.
If you need tool results to enter memory, write them yourself via higher-level logic before calling record(...).

Builder reference