Memory Session Ensure
memory_session_ensureOne-call session bootstrap: recover the active session or open one.
Replaces the memory_state_get → memory_session_close →
memory_session_open → memory_state_set ritual. Reuses the session in
the conversation/active-session state pointer when it is still
open and owned by the caller; otherwise closes it (distilling) and
opens a fresh one, updating state. Returns {session_id, agent, resumed, soul, soul_linked}. When the bearer is linked to a human
account, soul is their private compressed identity block for this
org (may be empty string if not yet written). When playbook_slug
or a work_id with a bound slug resolves, also returns playbook
{name, description, body_md, slug} (skill-expanded, capped) on
both fresh and resume paths.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ttl | No | Session TTL in seconds (default from server config) | |
| repo | Yes | Workspace slug (absolute path with leading / removed and / replaced by -). Keys the conversation/active-session state pointer. | |
| user | No | Substantive user request for this turn. When set, appended as the user turn in the same call (replaces a separate memory_session_append). | |
| agent | No | Override agent identity | |
| fresh | No | Force rotation: close any stored session (queueing distillation) and open a new one. Pass true on the first turn of a new chat. | |
| topic | No | What this session is about (used when opening a new one) | |
| github | No | GitHub owner/repo; distilled memories inherit the tag | |
| work_id | No | Work item UUID. When set and playbook_slug is omitted, that item's playbook_slug is injected on the ensure payload. | |
| playbook_slug | No | Named playbook to attach (wins over the work item's slug). Unset/missing/cross-org omits playbook — never dumps the catalog. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||