Skip to main content

Overview

Close a coding session and optionally attach a summary. This marks the session’s ended_at timestamp and stores any provided summary text.
This tool is part of the agent profile and uses deferred loading.

Parameters

string
required
Session identifier to closeMust match the id used in mem_session_start. If the session doesn’t exist, an error is returned.
string
Summary of what was accomplished during the sessionA brief description of the session’s work. For detailed summaries, use mem_session_summary instead, which creates a structured observation.This field is stored directly on the session record and is useful for quick session overviews.

Response

string
Confirmation message with session ID
Example:

Usage Examples

End Session Without Summary

Response:

End Session With Summary

Response:

Session End vs Session Summary

Two ways to summarize:
  1. mem_session_end with summary parameter (simple):
    • Stores a short summary on the session record
    • Good for brief overviews
    • Doesn’t create a searchable observation
  2. mem_session_summary (recommended for detailed work):
    • Creates a structured observation with Goal/Instructions/Discoveries/Accomplished/Files format
    • Searchable via mem_search
    • Provides rich context for future sessions
    • Referenced 16 times across agent protocols
For significant work, use both: call mem_session_summary first, then mem_session_end with a brief summary.

Session Lifecycle

When to Use

  • Session completion: When the coding session is definitively over
  • Agent shutdown: Before the agent exits
  • Timeout/idle: When a session has been inactive and should close
  • Manual end: When using CLI or API to close a session

Idempotency

This tool is idempotent — calling it multiple times on the same session won’t cause errors. The ended_at timestamp and summary will be updated on subsequent calls.

What Gets Updated

The session record is updated with:
  • ended_at: ISO 8601 timestamp of when mem_session_end was called
  • summary: The summary text (if provided)
Previously saved observations and prompts associated with the session remain unchanged.

Error Handling

If the session ID doesn’t exist:
Make sure to call mem_session_start before mem_session_end.