memory_session_ensure
One-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, profile}. 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). profile is the
same token-capped bootstrap object as memory_profile_get. When
playbook_slug or a work_id with a bound slug resolves, also
returns playbook {name, description, body_md, slug}
(its cited skills listed by name and when to load them with
memory_skill_get, not their bodies; capped) on both fresh and
resume paths. Also
org + bound + bound_scope. On unbound /mcp, a user
account with several orgs may include warnings suggesting
org_bind(slug=...) (CLI teamshared org bind is optional).
Optional auto_recall=true attaches budgeted recall hits (same
provenance citation shape as memory_recall) when
user= and/or topic= is set (thin-client bootstrap). Prefer
an explicit memory_recall for keyword anchors.
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. | |
| namespace | No | Limit the attached profile facts/episodes to this org-allowlisted container. Omit for shared-org profile. Invalid/unknown slugs fail. | |
| auto_recall | No | Opt-in thin-client bootstrap: when true and user= and/or topic= is set, run a budgeted memory_recall (k=5, explain=false, short deadline) over that text and attach hits as auto_recall. Missing both skips without error. Default false — existing callers are unchanged. Prefer an explicit memory_recall with a short keyword anchor; this is not a replacement. | |
| 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 | |||