All Products
Search
Document Center

Tablestore:Memory Dream

Last Updated:Sep 24, 2026

Dream asynchronously analyzes existing content in a memory store to merge, deduplicate, correct, and reorganize it.

Dream supports two types of memory stores, structured and file. The task interfaces are the same, but the results are applied differently.

Memory store

Input

Output method

Structured memory store

Long-term memory and raw messages

Generates proposals, or applies long-term memory actions by confidence threshold or approved plan

Writable file memory store

Text files in one or more scopes

Automatically writes to a single deterministic output scope

Structured memory Dream

As conversations are continuously written, long-term memory can accumulate duplicates, inconsistent wording, mergeable entries, or outdated items. Structured memory Dream refines the ingested long-term memory and raw messages in the background and produces applicable consolidation actions, keeping the memory store concise and consistent over time. It supports two modes: generating proposals for manual confirmation first, and automatically applying actions once a confidence threshold is reached.

How it works

Dream takes data in the memory store as input; the service analyzes it in the background and produces consolidation actions. Based on the consolidation target, tasks fall into three types. Actions from memory tasks are written back to the memory store, whereas actions from skill / profile tasks are produced only as standalone events, are not written to the memory store, and are consumed by the caller as needed.

taskType

Consolidation target

Produced action types

memory (default)

Long-term memory: rewrite, merge, deduplicate, and delete outdated items. Applied actions directly update the memory store.

ADD / UPDATE / DELETE / MERGE / NOOP

skill

Extracts reusable skills from historical interactions. Actions are produced as events and are not written to the memory store.

EMIT_SKILL

profile

Accumulates a structured user profile. Actions are produced as events and are not written to the memory store.

EMIT_PROFILE

Depending on how much your business trusts the consolidation results, you can choose one of the following apply modes.

applyMode

Behavior

proposal (default)

Consolidation only generates action proposals in the proposed state, which the caller applies explicitly through ApplyMemoryDreamActions.

safe_auto

Actions that reach the confidence threshold (confidenceThresholds) are applied automatically by the service; the rest are kept as proposals.

plan

High-effort consolidation first generates a plan that includes a deletion allowlist and enters awaiting_plan_approval; it executes only after the caller approves.

Note
  • applyMode is only supported when taskType=memory; passing skill / profile returns a 400 parameter error. skill / profile task actions (EMIT_SKILL / EMIT_PROFILE) are produced as events, are not written to the memory store, and are consumed and handled by the caller — there is no apply flow.

  • effort controls the consolidation intensity: low (default) runs a single bounded analysis; high allows multiple rounds of analysis. effort=high memory consolidation must explicitly select safe_auto or plan; applyMode=plan must use effort=high.

Quick start

The full workflow for structured memory Dream is: create a consolidation task → poll the task status → review action proposals → apply actions. After applying, you can read back long-term memory to verify the results.

The typical status flow is: queued → running → planning → (optional applying) → completed; plan mode enters awaiting_plan_approval before execution. Other terminal states include completed_with_failures, failed, cancelled. The following example uses proposal mode:

Console

Step 1: Create a consolidation task

  1. Log on to the memory store and, in the left-side navigation, choose Agentic Task > Memory Dream.

  2. In the upper-right corner, click Create Task, and configure the following parameters in the dialog box:

    Form item

    Description

    Corresponding parameter

    Task type

    Select Memory consolidation.

    taskType=memory

    Input scope

    The scope to consolidate. You can use the * wildcard to cover multiple levels.

    scopes

    Processing depth

    Standard (a single bounded analysis) or High-effort (multiple rounds of analysis).

    effort=low / high

    Apply mode

    Generate suggestions only (recommended; apply after manual confirmation).

    applyMode=proposal

    Output scope mode

    Preserve the original scope or Promote the scope.

    scopeOutputMode=preserve_scope / promote_scope

    Consolidation instructions

    Optional. Custom consolidation requirements.

    instructions

  3. After submission, the task runs asynchronously and generates a task ID (dreamId). The status starts flowing from queued.

    When you select High-effort for the processing depth, the apply mode must be safe_auto or plan (the constraint for effort=high).

Step 2: Review the task and suggestions

  1. In the Memory Dream task list, wait for the target task status to become Completed (completed). You can click Refresh to update the status.

  2. Click the task to open its details and view the produced action list. Each action contains the action type (ADD / UPDATE / DELETE / MERGE / NOOP), the target memory, the new consolidated content, the reason (reason), the confidence (confidence), and the status.

  3. proposal mode, all actions are initially To be applied (proposed), and they do not change the memory store until applied.

Step 3: Apply actions and verify

  1. In the task details, select the actions to apply (NOOP means no change is needed and can be left unselected).

  2. Click Apply. The service updates long-term memory according to the selected actions. DELETE actions cannot be recovered after deletion.

  3. plan mode, you must first approve the deletion allowlist in the plan before execution.

  4. After applying, read back the memory list under Memory data management > Long-term memory to confirm that the consolidation results meet expectations.

SDK

Call the four interfaces in sequence: create the task, poll the status, review action proposals, and apply actions.

Python

from tablestore_agent_storage import AgentStorageClient

client = AgentStorageClient(
    api_key="<your-api-key>",
    ots_endpoint="https://<instance>.<region>.ots.aliyuncs.com",
    ots_instance_name="<instance-name>",
)

# 1. Create the consolidation task
resp = client.create_memory_dream_task({
    "memoryStoreName": "agent_memory",
    "scopes": [{"appId": "app-001", "tenantId": "user-001", "agentId": "assistant", "runId": "session-001"}],
    "taskType": "memory",
    "effort": "low",
    "applyMode": "proposal",
    "instructions": "Merge duplicate memories and delete outdated items",
    "clientToken": "dream-001",
})
dream_id = resp.get("dreamId")

# 2. Poll the task status until it reaches a terminal state
task = client.get_memory_dream_task({
    "memoryStoreName": "agent_memory",
    "dreamId": dream_id,
})
print(f"status: {task.get('status')}, actions: {task.get('actions')}")

# 3. Review action proposals
actions = client.list_memory_dream_actions({
    "memoryStoreName": "agent_memory",
    "dreamId": dream_id,
    "limit": 100,
}).get("actions", [])

# 4. Apply the selected actions (skip NOOP)
client.apply_memory_dream_actions({
    "memoryStoreName": "agent_memory",
    "dreamId": dream_id,
    "mode": "actions",
    "actionIds": [a["actionId"] for a in actions if a["action"] != "NOOP"],
    "applier": "operator-001",
})

TypeScript

import { AgentStorageClient } from '@tablestore/agent-storage';

const client = new AgentStorageClient({
  apiKey: '<your-api-key>',
  endpoint: 'https://<instance>.<region>.ots.aliyuncs.com',
  instanceName: '<instance-name>',
});

// 1. Create the consolidation task
const created = await client.createMemoryDreamTask({
  memoryStoreName: 'agent_memory',
  scopes: [{ appId: 'app-001', tenantId: 'user-001', agentId: 'assistant', runId: 'session-001' }],
  taskType: 'memory',
  effort: 'low',
  applyMode: 'proposal',
  instructions: 'Merge duplicate memories and delete outdated items',
  clientToken: 'dream-001',
});
const dreamId = created.dreamId;

// 2. Poll the task status until it reaches a terminal state
const task = await client.getMemoryDreamTask({
  memoryStoreName: 'agent_memory',
  dreamId,
});
console.log(task.status, task.actions);

// 3. Review action proposals
const { actions } = await client.listMemoryDreamActions({
  memoryStoreName: 'agent_memory',
  dreamId,
  limit: 100,
});

// 4. Apply the selected actions (skip NOOP)
await client.applyMemoryDreamActions({
  memoryStoreName: 'agent_memory',
  dreamId,
  mode: 'actions',
  actionIds: actions.filter((a) => a.action !== 'NOOP').map((a) => a.actionId),
  applier: 'operator-001',
});

Key parameters

The following table lists the key parameters for creating a consolidation task. For the value range of each parameter, see Limitations and notes.

Parameter

Description

scopes

The list of scopes to consolidate. Required. Up to 20.

actionIds

The list of action IDs when applying actions. Required for ApplyMemoryDreamActions; an empty array is not allowed. Obtain it from the ListMemoryDreamActions response.

confidenceThresholds

Auto-apply thresholds. The keys are add / update / merge, with values in the range 0~1.DELETE actions do not support auto thresholds and are always kept as proposals.

scopeOutputMode

Where the consolidation results belong: preserve_scope (default, keeps the original scope) / promote_scope (promotes to a higher level).

incremental

true consolidates incrementally from the last successfully processed progress (suitable for scheduled triggering); the default false consolidates everything.

minTimestamp / maxTimestamp

Limit the message time range to consolidate.

maxSessions

The maximum number of sessions processed in a single consolidation.

maxMessages

The maximum number of messages processed in a single consolidation.

maxMemories

The maximum number of memories processed in a single consolidation.

expandedScopeLimit

The maximum number of scopes after expansion.

instructions

Custom consolidation instructions. Up to 4,000 characters.

Usage recommendations

  • Do not block online request paths while waiting for consolidation results. Consolidation tasks run asynchronously in the background; poll GetMemoryDreamTask to get progress.

  • In production, prefer proposal mode and apply only after manual or programmatic confirmation with apply. When you trust the results enough, set reasonable add / update / merge for confidenceThresholds, and enable safe_auto mode.

  • For scheduled consolidation, use incremental=true to avoid reprocessing everything each time.

File memory Dream

File memory Dream asynchronously consolidates text files in a writable file memory store. It can read existing files from one or more scopes and automatically write the complete deduplicated, summarized, corrected, and reorganized result to a single deterministic output scope.

Applicability

Before you use file memory Dream, make sure the memory store meets the following conditions:

  • The memory store was created with inputType=file and outputTypes=["file"]. Read-only files generated from messages do not support file Dream.

  • The input and output must belong to the same memory store. The input can span scopes, but the output must be a complete four-level scope without wildcards.

  • Only UTF-8 text files are consolidated; binary files and the /.wiki/ system path are excluded from consolidation.

  • A single task accepts up to 8 scope selectors. Wildcard scopes are expanded by level from the right, and the number of expanded scopes is limited by expandedScopeLimit.

Scenarios suited to file Dream include merging multiple run records of the same agent into a shared handbook, consolidating project conventions from multiple agents, merging duplicate files, or reorganizing directories while preserving source differences.

Quick start

The following example consolidates all run records of two agents into a shared scope.

Python

from tablestore_agent_storage import AgentStorageClient

client = AgentStorageClient(
    api_key="<your-api-key>",
    ots_endpoint="https://<instance>.<region>.ots.aliyuncs.com",
    ots_instance_name="<instance-name>",
)

output_scope = {
    "appId": "project-app",
    "tenantId": "team-a",
    "agentId": "shared-agent",
    "runId": "knowledge",
}

# 1. Create the task: read files from multiple input scopes; the consolidated result is automatically written to the single output scope
resp = client.create_memory_dream_task({
    "memoryStoreName": "agent_files",
    "scopes": [
        {"appId": "project-app", "tenantId": "team-a", "agentId": "research-agent", "runId": "*"},
        {"appId": "project-app", "tenantId": "team-a", "agentId": "coding-agent", "runId": "*"},
    ],
    "outputScope": output_scope,
    "instructions": "Organize project materials by topic and remove duplicate content; when conflicts exist, preserve the applicable scope and the differences.",
    "maxItems": 1000,
    "expandedScopeLimit": 200,
    "clientToken": "project-file-dream-001",
})
dream_id = resp.get("dreamId")

# 2. Poll the task until it reaches a terminal state
task = client.get_memory_dream_task({
    "memoryStoreName": "agent_files",
    "dreamId": dream_id,
})
print(f"status: {task.get('status')}, actions: {task.get('actions')}")

# 3. Check the file changes actually performed by the service
actions = client.list_memory_dream_actions({
    "memoryStoreName": "agent_files",
    "dreamId": dream_id,
    "limit": 100,
}).get("actions", [])

# 4. Read back the result files under the output scope
items = client.list_items({
    "memoryStoreName": "agent_files",
    "scope": output_scope,
    "limit": 100,
}).get("items", [])
for it in items:
    doc = client.get_item({
        "memoryStoreName": "agent_files",
        "scope": output_scope,
        "path": it["path"],
    })
    print(doc.get("path"), doc.get("content"))

TypeScript

import { AgentStorageClient } from '@tablestore/agent-storage';

const client = new AgentStorageClient({
  apiKey: '<your-api-key>',
  endpoint: 'https://<instance>.<region>.ots.aliyuncs.com',
  instanceName: '<instance-name>',
});

const outputScope = {
  appId: 'project-app',
  tenantId: 'team-a',
  agentId: 'shared-agent',
  runId: 'knowledge',
};

// 1. Create the task: read files from multiple input scopes; the consolidated result is automatically written to the single output scope
const created = await client.createMemoryDreamTask({
  memoryStoreName: 'agent_files',
  scopes: [
    { appId: 'project-app', tenantId: 'team-a', agentId: 'research-agent', runId: '*' },
    { appId: 'project-app', tenantId: 'team-a', agentId: 'coding-agent', runId: '*' },
  ],
  outputScope,
  instructions: 'Organize project materials by topic and remove duplicate content; when conflicts exist, preserve the applicable scope and the differences.',
  maxItems: 1000,
  expandedScopeLimit: 200,
  clientToken: 'project-file-dream-001',
});
const dreamId = created.dreamId;

// 2. Poll the task until it reaches a terminal state
const task = await client.getMemoryDreamTask({
  memoryStoreName: 'agent_files',
  dreamId,
});
console.log(task.status, task.actions);

// 3. Check the file changes actually performed by the service
const { actions } = await client.listMemoryDreamActions({
  memoryStoreName: 'agent_files',
  dreamId,
  limit: 100,
});

// 4. Read back the result files under the output scope
const { items } = await client.listItems({
  memoryStoreName: 'agent_files',
  scope: outputScope,
  limit: 100,
});
for (const it of items) {
  const doc = await client.getItem({
    memoryStoreName: 'agent_files',
    scope: outputScope,
    path: it.path,
  });
  console.log(doc.path, doc.content);
}
  • For file Dream, taskType is fixed to memory (can be omitted), effort is fixed to high, applyMode is fixed to auto (all can be omitted). Do not pass message time windows, incremental, scopeOutputMode, confidenceThresholds, maxSessions, maxMessages or maxMemories. Reuse the same clientToken when retrying the same business request to avoid creating duplicate tasks.

  • get_memory_dream_task echoes the input selectors, the actually expanded scopes, the output scope, and the number of frozen files. Terminal states include completed, completed_with_failures, failed, cancelled; only completed with zero failed actions counts as a full success.

  • File actions use ADD, UPDATE, DELETE; a rename appears as an UPDATE with a new path. itemChange.sourceVersionIds records the file versions the consolidation was based on, and returns resultItemId and resultVersionId on a successful write. If list_memory_dream_actions returns a nextToken, keep paging until it is empty.

  • File actions are applied automatically during task execution and do not require manual confirmation. Do not judge consolidation quality by task status or action count alone; read back the output directory, content, versions, and sources to confirm they meet your business requirements.

Limits and considerations

Item

Limit or behavior

Input scope selectors

1 to 8

Output scope

A single complete four-level scope; wildcards are not allowed

expandedScopeLimit

Default 200, maximum 1000

maxItems

Default 1000, maximum 5000; includes deduplicated input files and existing files in the output scope

instructions

Up to 4,000 bytes (UTF-8)

File type

UTF-8 text files only; up to 100 KiB per file

System path

Does not read from or write to /.wiki/

Apply method

Automatic write; proposal, safe_auto, plan, and manual Apply are not supported

During task execution, every update and delete uses file versions for concurrency protection. When other callers modify the output files at the same time, actions may fail; re-read the current files and then create a new consolidation task.

Cancellation or failure does not roll back file actions that have already been applied. When you handle a non-successful terminal state, first list all actions and read back the output scope, then decide whether to keep, fix, or re-consolidate.