Skip to main content
Glama

end_session

End the current session by storing checkpoint, decisions, open loops, and preferences as structured records to preserve continuity for the next session.

Instructions

End the current session. Stores a checkpoint, decisions, open loops, preferences, constraints, warnings, and relational delta as structured continuity records. Creates a session record. Call this at the end of every substantive session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
checkpointYesWhere we left off — the single most important handoff artifact
decisionsNoWhat was decided and why
open_loopsNoUnresolved questions or tasks
preferencesNoNew user preferences learned this session
constraintsNoBoundaries that must not be violated — violating these causes trust damage
warningsNoThings the next session should be careful about
relational_deltaNoWhat changed in the working relationship this session — trust changes, tension, repair, tone shifts
next_session_focusNoWhere to resume next session (vs where we stopped)
projectNoProject scope
transcript_pathNoPath to session transcript file

Implementation Reference

  • The async handler function that executes the end_session tool logic. Creates a session, stores checkpoint, decisions, open loops, preferences, constraints, warnings, relational delta, and next_session_focus as structured continuity records. Returns a JSON summary of what was stored.
      async ({
        checkpoint,
        decisions,
        open_loops,
        preferences,
        constraints,
        warnings,
        relational_delta,
        next_session_focus,
        project,
        transcript_path,
      }) => {
        const sessionId = storage.createSession({
          summary: "",
          transcriptPath: transcript_path,
          project,
        });
    
        const stored: StoredRecord[] = [];
        const endSessionOpts = (type: string) => ({
          type,
          source: "end_session" as const,
          session_id: sessionId,
        });
    
        const cpId = storage.store(
          checkpoint,
          "context",
          8,
          project,
          endSessionOpts("checkpoint")
        );
        stored.push({ type: "checkpoint", id: cpId, content: checkpoint });
    
        for (const d of decisions ?? []) {
          const id = storage.store(d, "context", 7, project, endSessionOpts("decision"));
          stored.push({ type: "decision", id, content: d });
        }
    
        for (const ol of open_loops ?? []) {
          const id = storage.store(ol, "context", 7, project, endSessionOpts("open_loop"));
          stored.push({ type: "open_loop", id, content: ol });
        }
    
        for (const p of preferences ?? []) {
          const id = storage.store(p, "preference", 6, project, endSessionOpts("preference"));
          stored.push({ type: "preference", id, content: p });
        }
    
        for (const c of constraints ?? []) {
          const id = storage.store(c, "lesson", 9, project, endSessionOpts("constraint"));
          stored.push({ type: "constraint", id, content: c });
        }
    
        for (const w of warnings ?? []) {
          const id = storage.store(w, "lesson", 8, project, endSessionOpts("warning"));
          stored.push({ type: "warning", id, content: w });
        }
    
        if (relational_delta) {
          const id = storage.store(
            relational_delta,
            "relationship",
            8,
            project,
            endSessionOpts("relational_delta")
          );
          stored.push({ type: "relational_delta", id, content: relational_delta });
        }
    
        if (next_session_focus) {
          const id = storage.store(
            next_session_focus,
            "context",
            7,
            project,
            endSessionOpts("next_session_focus")
          );
          stored.push({ type: "next_session_focus", id, content: next_session_focus });
        }
    
        const counts: Record<string, number> = {};
        for (const r of stored) {
          counts[r.type] = (counts[r.type] ?? 0) + 1;
        }
    
        const summaryParts = [`Checkpoint: ${checkpoint}`];
        if (decisions?.length) summaryParts.push(`Decisions: ${decisions.length}`);
        if (open_loops?.length) summaryParts.push(`Open loops: ${open_loops.length}`);
        if (preferences?.length) summaryParts.push(`Preferences: ${preferences.length}`);
        if (constraints?.length) summaryParts.push(`Constraints: ${constraints.length}`);
        if (warnings?.length) summaryParts.push(`Warnings: ${warnings.length}`);
        if (relational_delta) summaryParts.push(`Relational delta captured`);
        if (next_session_focus) summaryParts.push(`Next focus set`);
    
        const summary = summaryParts.join(". ");
    
        const session = storage.getSession(sessionId);
        if (session) {
          storage.updateSession(sessionId, {
            summary,
            checkpointMemoryId: cpId,
          });
        }
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify({
                session_id: sessionId,
                stored_count: stored.length,
                stored: counts,
                summary,
                message:
                  "Session captured. Next boot will load the checkpoint; open loops and other continuity records are stored and searchable.",
              }, null, 2),
            },
          ],
        };
      }
    );
  • Zod schema defining the input parameters for end_session: checkpoint (required string), decisions, open_loops, preferences, constraints, warnings (arrays of strings), relational_delta, next_session_focus, project, transcript_path (optional strings).
    {
      checkpoint: z
        .string()
        .describe("Where we left off — the single most important handoff artifact"),
      decisions: z
        .array(z.string())
        .optional()
        .describe("What was decided and why"),
      open_loops: z
        .array(z.string())
        .optional()
        .describe("Unresolved questions or tasks"),
      preferences: z
        .array(z.string())
        .optional()
        .describe("New user preferences learned this session"),
      constraints: z
        .array(z.string())
        .optional()
        .describe("Boundaries that must not be violated — violating these causes trust damage"),
      warnings: z
        .array(z.string())
        .optional()
        .describe("Things the next session should be careful about"),
      relational_delta: z
        .string()
        .optional()
        .describe(
          "What changed in the working relationship this session — trust changes, tension, repair, tone shifts"
        ),
      next_session_focus: z
        .string()
        .optional()
        .describe("Where to resume next session (vs where we stopped)"),
      project: z.string().optional().describe("Project scope"),
      transcript_path: z
        .string()
        .optional()
        .describe("Path to session transcript file"),
    },
  • The registerEndSession function signature - registers the 'end_session' tool on the McpServer.
    export function registerEndSession(
      server: McpServer,
      storage: RekindleStorage
    ): void {
  • src/server.ts:24-24 (registration)
    Registration call site in server.ts where registerEndSession is invoked with the server and storage instances.
    registerEndSession(server, storage);
  • Helper function endSessionOpts that generates the metadata options object (type, source='end_session', session_id) passed to storage.store for each stored record.
    const endSessionOpts = (type: string) => ({
      type,
      source: "end_session" as const,
      session_id: sessionId,
    });
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description must disclose behavioral traits. It lists what the tool stores (checkpoint, decisions, etc.) and that it creates a session record, but does not mention side effects, error conditions, idempotency, or required permissions. The behavioral disclosure is minimal.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences, each serving a distinct purpose: action, stored content, usage instruction. No redundant or filler language. The core action is front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (10 parameters, no output schema), the description adequately explains the tool's purpose, stored data, and when to call. It does not detail return values (unnecessary without output schema) or error handling, but for a session-ending tool, it is fairly complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 10 parameters with full descriptions (100% coverage). The description adds that these are stored as 'structured continuity records' but does not provide additional meaning beyond the schema. Baseline 3 is appropriate since the schema already does heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's main action: 'End the current session.' It enumerates the stored records (checkpoint, decisions, etc.) and explicitly states it creates a session record. No sibling tool overlaps; they are all memory-related, so clear differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly instructs to 'Call this at the end of every substantive session.' This provides a clear and specific usage context. No alternative tools are mentioned, but given sibling tools are unrelated to session management, this is sufficient.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Skitchy/rekindle'

If you have feedback or need assistance with the MCP directory API, please join our Discord server