save_memory
Persist a learning note with linked SLayer entities or query, returning a memory id for later retrieval.
Instructions
Save an agent memory: a free-form note plus the SLayer entities it concerns.
linked_entities accepts either:
a list of entity reference strings — each item is resolved to the canonical
<datasource>.<model>[.<leaf>]form. Bare names use the datasource priority list; ambiguous bare-column matches are rejected.memory:<id>is also valid here (cross-memory references; the target memory must exist).a
SlayerQuery(dict) — entities are auto-extracted fromsource_model,dimensions,time_dimensions,measures, andfilters; resolution warnings are non-fatal. The query itself is stored alongside the learning, so the memory surfaces insearch'sexample_querieslist (vs thememorieslist for entity-list memories).
DEV-1428: id is an optional canonical memory id. Omit to
auto-allocate a monotonic int-shaped id ("1", "2", ...);
supply a string for a stable user-controlled id
("kb.policy.42"). Charset excludes :, /, ?,
#, whitespace. Duplicate id → unconditional upsert,
created_at preserved.
Returns the assigned memory_id (string), the canonical
entities stored, and any non-fatal warnings.
Cascade-on-delete: when a model / datasource / measure is
deleted, every memory:<id> and <ds>.<model>[.<leaf>]
reference under it is automatically stripped from every other
memory's entities list. Memories with zero entities after
the strip are kept (the learning text stands alone).
Search is lenient: stale entity tags in saved memories are filtered out at retrieval time rather than raising.
Args:
learning: The note text. Required, non-empty.
linked_entities: List of entity strings, or an inline
SlayerQuery payload.
id: Optional canonical memory id (see above).
Examples: save_memory( learning="orders.is_returned in {0,1,NULL}; treat NULL as not returned", linked_entities=["orders.is_returned"], )
save_memory(
learning="Paid revenue by status",
linked_entities={
"source_model": "orders",
"measures": [{"formula": "amount:sum"}],
"filters": ["status = 'paid'"],
},
id="kb.paid-revenue",
)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | ||
| learning | Yes | ||
| description | No | ||
| linked_entities | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |