Skip to main content

Overview

Create a new session record to track the beginning of a coding session. Sessions group related observations and provide chronological context for memory retrieval.
This tool is part of the agent profile and uses deferred loading.

Parameters

string
required
Unique session identifierShould be unique across all sessions. Common patterns:
  • UUIDs: 550e8400-e29b-41d4-a716-446655440000
  • Timestamped: session-2026-03-03-1430
  • Agent-generated: opencode-abc123
This ID is used to associate observations with the session via mem_save, mem_save_prompt, etc.
string
required
Project nameThe name of the project being worked on. Used for filtering and grouping memories.Examples: engram, my-api, frontend-app
string
Working directory pathThe file system path where the session is running. Useful for context but not required.Example: /home/user/projects/engram

Response

string
Confirmation message with session ID and project
Example:

Usage Examples

Basic Session Start

Response:

With Working Directory

Response:

Session Lifecycle

  1. Start: Call mem_session_start at the beginning of a coding session
  2. Work: Use mem_save, mem_search, mem_context, etc. during the session
  3. Summarize: Call mem_session_summary when significant work is complete
  4. End: Call mem_session_end to mark the session complete

When to Use

  • Agent initialization: When an AI coding assistant starts working
  • Manual sessions: When using the CLI or API directly
  • Session tracking: To maintain chronological context across multiple interactions

Idempotency

This tool is idempotent — calling it multiple times with the same id won’t create duplicate sessions. If the session already exists, the call succeeds without error.

What Gets Created

A session record with:
  • id: The session identifier
  • project: Project name
  • directory: Working directory (if provided)
  • started_at: ISO 8601 timestamp of creation
  • ended_at: null until mem_session_end is called
  • summary: null until mem_session_end is called

Session ID Best Practices

Generate stable session IDs that can be used consistently throughout a coding session:
  • Use UUIDs for guaranteed uniqueness
  • Use timestamps if you only run one session at a time per project
  • Include the agent name for debugging: opencode-{uuid}
  • Store the session ID in agent state so all tool calls use the same ID