memory_session_finish
End an open session, optionally saving a distilled handoff of outcomes and next actions to guide future sessions.
Instructions
Close an open session bracket (exactly once) with an optional summary — and an OPTIONAL handoff: the distilled close (what became true / what is open / the next physical action). A present handoff is captured as a NORMAL capsule through the audited ingest path BEFORE the bracket closes — provenance source "memory_session_finish", anchor = the session id, linked to the bracket; project-fence defaults, taint scan, and idempotent dedup all apply — and memory_digest then LEADS with the newest handoff per project (its handoff section), so the next cold session reads the close first. The response names the capsule (handoff_capsule; handoff_deduped: true when the content collapsed onto an existing capsule). A value-rejected handoff (e.g. empty content) fails the WHOLE call with -32602 naming the param — fail closed: nothing captured, the session stays open. A closed bracket accepts no further captures. Both state faults are typed resource-state errors, one family (-32002 + data {kind, id}): an unknown id → {kind: "unknown_session", id}; finishing an already-finished bracket → {kind: "finished_session", id} (never a discriminator-less invalid-params) — a handoff never leaks a capture past either. Audited.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| handoff | No | R6: optional distilled handoff — what became true, what is open, the next physical action. When present it is captured as a NORMAL capsule through the audited ingest path BEFORE the bracket closes (provenance source [`HANDOFF_SOURCE`], anchor = this session id, linked to the bracket; fences, taint scan, and dedup all apply), and `memory_digest` then leads with the newest handoff per project. When absent, finish behaves exactly as before. | |
| summary | No | Optional close-time summary, recorded on the session row. | |
| session_id | Yes | The open session to close (`sess-<n>`). |