session
Persists and restores task context as one living Markdown note per line of work, letting agents save progress, resume tasks, and archive completed work.
Instructions
Keep the session state: one living note per line of work in sesiones//.
Only this tool writes there (revise and remember refuse it). The state in use is the one this process saved or restored, else the newest active state of the same worktree (project_dir). save: create or rewrite the whole state. Target: note, else the current state, else a new one (needs title); to start another line of work, archive the current state first. A note that was archived becomes active again. body replaces the body (a leading "# title" line is dropped); a credential in title, body, files or session is refused (invalid_argument). Returns {"path", "created", "missing_sections"} plus "template_hint" when a long body lacks template sections; it never refuses for format. plan (a slug of the plan tool) links the state to its plan; without it the state keeps its plan, else takes the plan this process saved last for the worktree. The extractor passes until (the last transcript time it read) and the next extraction order starts there, not at saved_at; any later save drops it. show: {"found", "path", "task_title", "saved_at", "content"} (plus "extracted_until" when the extractor saved last). Never writes. restore: the state as context, made current: {"found", "path", "task_title", "saved_at", "content", "source"}. Without a state it falls back to the deprecated checkpoint when [checkpoint] state_glob is set (adds "deprecated"). template: {"type", "sections", "skeleton"} of type (default "session"). archive: set status archived on note (default the current state); never deletes. Returns {"path", "changed"}. States more than [session] archive_days (7) days after their saved_at are archived by the maintenance of the first welcome. Hook actions: gate (only with hook_event="PreCompact") blocks a manual /compact once when the state was not saved in 5+ messages; capture (PostCompact) puts summary in the "Resumen de compactación" section of the state, credentials redacted, creating «Sesión » if there is none; end (SessionEnd) keeps transcript for the next restore after /clear (only when reason is "clear" or empty). restore with source and a transcript adds "extract", the order to launch the episteme:extractor agent, when [session] extract is on.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"action": "<action>"
},
"name": "session"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | No | save: the whole state, following the session template (replaces it). | |
| note | No | save, archive: path of a state; default is the current state. | |
| plan | No | save: slug of the plan of the task; default keeps the state's plan. | |
| type | No | template: memory type; default "session". | |
| files | No | save: files the task touches (globs allowed). | |
| title | No | save: the task in a few words; needed to create a state. | |
| until | No | save with origin="extractor": the digest's "hasta" (ISO); the next extraction starts there. | |
| action | Yes | One of: save, show, restore, template, archive, capture, end, gate. | |
| origin | No | save: "agent" (default) or "extractor"; goes to saved_by. | |
| reason | No | end: why the session ended (${reason}). | |
| source | No | restore: "compact" or "clear" (${source}) from the hook. | |
| project | No | Project; defaults to --project. | |
| session | No | Claude Code session id (hooks pass ${session_id}); metadata for save. | |
| summary | No | capture: the compaction summary (${compact_summary}). | |
| trigger | No | gate: "manual" or "auto" (${trigger}). | |
| hook_event | No | Only for Claude Code hooks: ${hook_event_name}. Omit otherwise. | |
| transcript | No | end, restore: path of the session transcript (${transcript_path}). | |
| project_dir | No | Absolute project directory (hooks pass ${cwd}); picks the worktree. |