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 |
| Long-term memory: rewrite, merge, deduplicate, and delete outdated items. Applied actions directly update the memory store. |
|
| Extracts reusable skills from historical interactions. Actions are produced as events and are not written to the memory store. |
|
| Accumulates a structured user profile. Actions are produced as events and are not written to the memory store. |
|
Depending on how much your business trusts the consolidation results, you can choose one of the following apply modes.
applyMode | Behavior |
| Consolidation only generates action proposals in the |
| Actions that reach the confidence threshold ( |
| High-effort consolidation first generates a plan that includes a deletion allowlist and enters |
applyModeis only supported whentaskType=memory; passingskill/profilereturns a400parameter error.skill/profiletask 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 noapplyflow.effortcontrols the consolidation intensity:low(default) runs a single bounded analysis;highallows multiple rounds of analysis.effort=highmemory consolidation must explicitly selectsafe_autoorplan;applyMode=planmust useeffort=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
Log on to the memory store and, in the left-side navigation, choose Agentic Task > Memory Dream.
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=memoryInput scope
The scope to consolidate. You can use the
*wildcard to cover multiple levels.scopesProcessing depth
Standard (a single bounded analysis) or High-effort (multiple rounds of analysis).
effort=low/highApply mode
Generate suggestions only (recommended; apply after manual confirmation).
applyMode=proposalOutput scope mode
Preserve the original scope or Promote the scope.
scopeOutputMode=preserve_scope/promote_scopeConsolidation instructions
Optional. Custom consolidation requirements.
instructionsAfter submission, the task runs asynchronously and generates a task ID (
dreamId). The status starts flowing fromqueued.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
In the Memory Dream task list, wait for the target task status to become Completed (
completed). You can click Refresh to update the status.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.proposalmode, all actions are initially To be applied (proposed), and they do not change the memory store until applied.
Step 3: Apply actions and verify
In the task details, select the actions to apply (
NOOPmeans no change is needed and can be left unselected).Click Apply. The service updates long-term memory according to the selected actions.
DELETEactions cannot be recovered after deletion.planmode, you must first approve the deletion allowlist in the plan before execution.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 |
| The list of scopes to consolidate. Required. Up to 20. |
| The list of action IDs when applying actions. Required for |
| Auto-apply thresholds. The keys are |
| Where the consolidation results belong: |
|
|
| Limit the message time range to consolidate. |
| The maximum number of sessions processed in a single consolidation. |
| The maximum number of messages processed in a single consolidation. |
| The maximum number of memories processed in a single consolidation. |
| The maximum number of scopes after expansion. |
| 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
GetMemoryDreamTaskto get progress.In production, prefer
proposalmode and apply only after manual or programmatic confirmation withapply. When you trust the results enough, set reasonableadd/update/mergeforconfidenceThresholds, and enablesafe_automode.For scheduled consolidation, use
incremental=trueto 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=fileandoutputTypes=["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,
taskTypeis fixed tomemory(can be omitted),effortis fixed tohigh,applyModeis fixed toauto(all can be omitted). Do not pass message time windows,incremental,scopeOutputMode,confidenceThresholds,maxSessions,maxMessagesormaxMemories. Reuse the sameclientTokenwhen retrying the same business request to avoid creating duplicate tasks.get_memory_dream_taskechoes the input selectors, the actually expanded scopes, the output scope, and the number of frozen files. Terminal states includecompleted,completed_with_failures,failed,cancelled; onlycompletedwith zero failed actions counts as a full success.File actions use
ADD,UPDATE,DELETE; a rename appears as anUPDATEwith a newpath.itemChange.sourceVersionIdsrecords the file versions the consolidation was based on, and returnsresultItemIdandresultVersionIdon a successful write. Iflist_memory_dream_actionsreturns anextToken, 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 |
| Default 200, maximum 1000 |
| Default 1000, maximum 5000; includes deduplicated input files and existing files in the output scope |
| 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 |
Apply method | Automatic write; |
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.