Use Bailian CLI to add and search long-term memory, manage memory nodes and profile schemas, read user profiles, and export skill memories.
Long-term memory capabilities are currently available only to China site (aliyun.com) accounts.
Configure the workspace
Memory commands call the memory API through a workspace-specific endpoint, so every command requires a workspace ID, and the API key must belong to the same workspace. To get the workspace ID, see Authentication.
Provide the workspace ID in any of the following ways, listed from highest to lowest priority:
- The
--workspace-id <id>flag - The
BAILIAN_WORKSPACE_IDenvironment variable - The
workspace_idconfig field, e.g.bl config set workspace_id <id>
Command reference
| Capability | Command | Description |
|---|---|---|
| Add and search | bl memory add | Extract memory from messages, or store custom content verbatim (async extraction) |
bl memory search | Search memory nodes by query text or conversation context | |
| Memory node management | bl memory list | List a user's memory nodes page by page |
bl memory node show | Show the full details of a single memory node | |
bl memory update | Update the content of a memory node | |
bl memory delete | Delete a single memory node | |
| Profile schemas and user profiles | bl memory profile create | Create a profile schema |
bl memory profile list | List profile schemas page by page | |
bl memory profile show | Show a profile schema definition with attribute IDs | |
bl memory profile update | Update a profile schema, extraction scene, or plan version | |
bl memory profile delete | Delete a profile schema | |
bl memory profile get | Get the user profile extracted under a schema | |
| Skill memory | bl memory skill export | Export a skill memory node |
--workspace-id, --api-key, and global flags such as --output and --dry-run.
Add and search
bl memory add
Add memory from messages or custom content. The command submits an async extraction task, then polls it locally until every task finishes or the wait budget runs out.
Syntax
| Flag | Type | Required | Description |
|---|---|---|---|
--user-id <id> | string | Yes | Memory entity ID that owns the memory |
--messages <json> | string | No | Messages JSON array, e.g. [{"role":"user","content":"..."}]. role supports user, assistant, and tool; OpenAI tool_calls are supported. Up to 50 messages |
--content <text> | string | No | Custom content to store verbatim. If --messages is also passed, the server uses --content |
--profile-schema <id> | string | No | Profile schema ID. Without it, no user profile is extracted |
--extract-mode <profile_only> | string | No | Extract only the user profile. Requires --profile-schema and --messages; cannot be used with --content |
--skill-name <name> | string | No | Skill name for skill memory. Must be passed together with --skill-description and --skill-tags |
--skill-description <text> | string | No | Skill description for skill memory. Must be passed together with --skill-name and --skill-tags |
--skill-tags <tag> | array | No | Skill tag; repeatable. Must be passed together with --skill-name and --skill-description |
--meta-data <json> | string | No | Custom metadata JSON object, e.g. {"location_name":"Beijing"} |
--wait <seconds> | number | No | Polling budget in seconds. Default: 120. Set to 0 to return the event_id right after submission |
--project-id <id> | array | No | Memory fragment rule ID; repeatable. Message extraction accepts up to 5; custom content accepts 1 |
--library-id <id> | string | No | Memory library ID. Default: the account's default library |
- Pass at least one of
--contentand--messages. Passing only one is recommended. - One call can add, update, or delete several memory nodes at once. When the wait budget runs out, the command exits with a timeout while extraction may continue in the background. Check the results with
bl memory list,bl memory search, orbl memory profile getbefore deciding whether to resubmit. --wait 0returns only the submission receipt andevent_id; it does not mean extraction is complete.event_idis not a memory node ID. Usememory_node_idfrom list or search results as the node ID.- If some extraction tasks fail, the command exits with a non-zero code, and the output may still include the results of completed tasks.
- For adding user profiles and skill memories, see Profile schemas and user profiles and Skill memory.
bl memory search
Search memory nodes by query text or conversation context.
Syntax
| Flag | Type | Required | Description |
|---|---|---|---|
--user-id <id> | string | Yes | Memory entity ID that owns the memory |
--query <text> | string | No | Search text, sent as a single user message |
--messages <json> | string | No | Messages JSON array for context-based search; takes precedence over --query |
--top-k <n> | number | No | Maximum number of results, 1–100. Default: 10 |
--min-score <score> | number | No | Minimum similarity score, 0–1. Default: 0.3. Effective only with the pro plan |
--memory-types <observation|skill> | array | No | Memory types to search; repeatable. Without it, the server searches observation only |
--memory-type <observation|skill> | string | No | Deprecated alias for --memory-types; cannot be combined with --memory-types |
--project-ids <id> | array | No | Memory fragment rule ID; repeatable |
--project-id <id> | array | No | Deprecated alias for --project-ids; cannot be combined with --project-ids |
--plan-version <pro|lite> | string | No | Plan version: pro (rerank on) or lite (rerank off), billed differently. Default on the server: pro |
--library-id <id> | string | No | Memory library ID. Default: the account's default library |
- Pass at least one of
--queryand--messages. If both are passed,--messagestakes precedence. - Plan versions differ in search strategy and billing, so do not compare scores across plans. See Pro vs Lite.
- An empty result is not an error. If a newly added memory is not found, first confirm that async extraction has finished, then check that
--user-id,--library-id, rule IDs, and memory types match those used when adding.
Memory node management
Node IDs come from memory_node_id in list or search results.
bl memory list
List a user's memory nodes page by page.
Syntax
| Flag | Type | Required | Description |
|---|---|---|---|
--user-id <id> | string | Yes | Memory entity ID that owns the memory |
--page-size <n> | number | No | Results per page. Default: 10 |
--page <n> | number | No | Page number. Default: 1 |
--project-id <id> | string | No | Memory fragment rule ID. Default: the library's default rule |
--library-id <id> | string | No | Memory library ID. Default: the account's default library |
- Without
--project-id, only nodes under the default rule are listed. Nodes under other fact or skill rules require the corresponding rule ID. - Each call returns one page. Adjust
--pageto get more results.
bl memory node show
Show the full details of a single memory node, including its type, status, content, and metadata.
Syntax
| Flag | Type | Required | Description |
|---|---|---|---|
--node-id <id> | string | Yes | Memory node ID |
- Before updating a node, you can use this command to check whether it is a skill memory.
- A deleted node may still return details with
statusset todelete.
bl memory update
Update the content of a memory node.
Syntax
| Flag | Type | Required | Description |
|---|---|---|---|
--node-id <id> | string | Yes | Memory node ID |
--content <text> | string | Yes | New content for the memory node, up to 512 characters |
--meta-data <json> | string | No | Custom metadata JSON object, merged incrementally, e.g. {"key":"value"} |
--skill-name <name> | string | No | Skill name for skill memory. Must be passed together with --skill-description and --skill-tags |
--skill-description <text> | string | No | Skill description for skill memory. Must be passed together with --skill-name and --skill-tags |
--skill-tags <tag> | array | No | Skill tag; repeatable. Must be passed together with --skill-name and --skill-description |
--library-id <id> | string | No | Memory library ID. Default: the account's default library |
--contentreplaces the node content in full,--meta-datais merged incrementally, and the node's original timestamps are kept.- If the target node is a skill memory, you must pass
--skill-name,--skill-description, and--skill-tagseven if you only change the content. - This command does not update extracted user profiles.
bl memory delete
Delete a single memory node.
Syntax
| Flag | Type | Required | Description |
|---|---|---|---|
--node-id <id> | string | Yes | Memory node ID |
--library-id <id> | string | No | Memory library ID. Default: the account's default library |
--yes | switch | Required to execute | Confirm the deletion. Not required with --dry-run |
- Only the specified node is deleted. Extracted user profile values and profile schemas are not deleted, and the user's other memories are kept.
- After deletion, the node details may still show
statusasdelete. Use list and search results to confirm the deletion.
Profile schemas and user profiles
A profile schema defines the attributes to extract and can be shared by multiple users. A user profile holds the attribute values extracted for one user under one schema. For the full workflow, see Use user profiles.
bl memory profile create
Create a profile schema.
Syntax
| Flag | Type | Required | Description |
|---|---|---|---|
--name <name> | string | Yes | Schema name |
--description <text> | string | No | Schema description |
--attributes <json> | string | Yes | Attributes JSON array, e.g. [{"name":"age","description":"age","default_value":"18"}]. Each attribute requires name; description and default_value are optional |
--plan-version <pro|lite> | string | No | Plan version: pro (rerank on) or lite (rerank off), billed differently |
--extract-scene <efficient|intelligent> | string | No | Extraction scene. Default on creation: efficient |
--library-id <id> | string | No | Memory library ID. Default: the account's default library |
profile_schema_id and pass it to bl memory add with --profile-schema to extract profiles under this schema. Use the same --library-id for later adds and reads.
bl memory profile list
List profile schemas page by page.
Syntax
| Flag | Type | Required | Description |
|---|---|---|---|
--page-size <n> | number | No | Results per page. Default: 10 |
--page <n> | number | No | Page number. Default: 1 |
--library-id <id> | string | No | Memory library ID. Default: the account's default library |
bl memory profile show
Show a profile schema definition with attribute IDs.
Syntax
| Flag | Type | Required | Description |
|---|---|---|---|
--schema-id <id> | string | Yes | Profile schema ID |
--library-id <id> | string | No | Memory library ID. Default: the account's default library |
attribute_id values are used by bl memory profile update to update or delete attributes.
bl memory profile update
Update the name, description, attributes, extraction scene, or plan version of a profile schema.
Syntax
| Flag | Type | Required | Description |
|---|---|---|---|
--schema-id <id> | string | Yes | Profile schema ID |
--name <name> | string | No | New schema name |
--description <text> | string | No | New schema description |
--attributes-operations <json> | string | No | Attribute operations JSON array, e.g. [{"op":"add","name":"plan"}] |
--plan-version <pro|lite> | string | No | Plan version: pro (rerank on) or lite (rerank off), billed differently |
--extract-scene <efficient|intelligent> | string | No | Extraction scene |
--library-id <id> | string | No | Memory library ID. Default: the account's default library |
- Besides
--schema-id, pass at least one field to update:--name,--description,--attributes-operations,--plan-version, or--extract-scene. - Each attribute operation requires
op:addrequiresname;updateanddeleterequireattribute_id. Get attribute IDs withbl memory profile show. - This command changes the shared schema, not one user's profile values. A
deleteoperation removes the attribute definition without a--yesconfirmation, so check the schema withbl memory profile showand preview the request with--dry-runfirst.
bl memory profile delete
Delete a profile schema.
Syntax
| Flag | Type | Required | Description |
|---|---|---|---|
--schema-id <id> | string | Yes | Profile schema ID |
--library-id <id> | string | No | Memory library ID. Default: the account's default library |
--yes | switch | Required to execute | Confirm the deletion. Not required with --dry-run |
bl memory profile get
Get the user profile extracted under a profile schema.
Syntax
| Flag | Type | Required | Description |
|---|---|---|---|
--schema-id <id> | string | Yes | Profile schema ID |
--user-id <id> | string | Yes | Memory entity ID that owns the profile |
--library-id <id> | string | No | Memory library ID. Default: the account's default library |
- Attribute values are extracted only after messages have been added with
bl memory add --profile-schemausing the same schema ID; otherwise every attribute comes back empty. - User profile values are updated through message extraction. The CLI does not provide commands to edit or delete a single attribute value directly, or to clear one user's profile.
Skill memory
Skill memory is a memory type in the memory library. Adding, searching, and updating skill memories use the add, search, and update commands, scoped by the ID of a skill-type memory fragment rule. The CLI does not provide commands to create or manage rules, so use an existing rule ID.
bl memory skill export
Export a skill memory node.
Syntax
| Flag | Type | Required | Description |
|---|---|---|---|
--node-id <id> | string | Yes | Skill memory node ID |
- Text output is the skill body without frontmatter. JSON output also includes
skill_name,skill_description, andskill_tags. - The command does not write files directly; use shell redirection to save the output. Exporting does not install the skill into any Agent.