Skip to main content
Glama

handleSessionEnd

Idempotent

Finalize a coding session by automatically summarizing ingested events into durable memory and pruning stale memories. Use after all events are ingested.

Instructions

Run the full session-end pipeline: auto-summarize the session's ingested events into a durable memory (when enough events exist) and apply a light retention prune of stale memories. Idempotent on the summary memory (upsert by sessionId).

WHEN TO CALL: Once, at the very end of a session, after ingesting session events via ingestSessionEvents. Lets sessionmem generate and store the session summary for you.

WHEN NOT TO CALL: Mid-session, or when you have already written your own summary (use summarizeSessionToMemory instead). On Claude Code this also runs automatically via the installed SessionEnd hook, so calling it explicitly is usually unnecessary there.

Provide sessionId and sourceAdapter. memoryId (optional) pins the summary's id; omit to derive ${sessionId}-summary. config (optional) tunes autoSummarize / minimumEventThreshold / cloud summarization; omit for sensible local-only defaults.

RESPONSE status is one of: 'stored', 'skipped_threshold' (too few events), 'skipped_disabled', 'failed'. warningCodes may carry cloud/local fallback signals.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
configNo
memoryIdNo
sessionIdYes
sourceAdapterYes
Behavior5/5

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

Annotations indicate idempotent and non-destructive. The description adds detail: idempotent via upsert by sessionId, response statuses ('stored', 'skipped_threshold', etc.), and mentions a 'light retention prune of stale memories'. No contradictions with annotations.

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?

The description is well-structured with sections for purpose, when to call/not call, parameter guidance, and response format. Each sentence adds value; no redundancy. Entire description fits a few paragraphs without being verbose.

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 (nested config, multiple response statuses, idempotency, pruning), the description covers the main aspects. It explains the response structure and what triggers skipping. However, it doesn't elaborate on the retention prune mechanism or how events are ingested. Still, it provides sufficient context for an agent to invoke correctly.

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

Parameters4/5

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

Input schema has no property descriptions (0% coverage), but the tool description compensates by explaining the required parameters (sessionId, sourceAdapter) and optional ones (memoryId pins summary id, config tunes behavior). It provides default values and high-level guidance, though some config sub-properties (e.g., anthropicApiKey, redactionEnabled) are not mentioned.

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 purpose: to run the full session-end pipeline including auto-summarization and retention pruning. It uses specific verbs ('run', 'auto-summarize', 'apply') and identifies the resource ('session's ingested events', 'durable memory'). It also distinguishes itself from the sibling tool 'summarizeSessionToMemory' by mentioning when to use that instead.

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?

Explicitly provides 'WHEN TO CALL' (once at session end after ingestSessionEvents) and 'WHEN NOT TO CALL' (mid-session, or if summary already written; on Claude Code it runs automatically). This gives clear context for when to use this tool vs. alternatives.

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/catfish-1234/sessionmem'

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