How It Works
Automatic Saving
Sessions are recorded automatically as you interact with the model—no manual saving required.
Project-Scoped Storage
Sessions are stored in
~/.gemini/tmp/<project_hash>/chats/ where <project_hash> is unique to your project directory.What Is Saved
Each session automatically captures:Conversation
Your prompts and the model’s responses
Tool Executions
All tool inputs and outputs
Token Usage
Input, output, cached tokens, and statistics
Reasoning
Assistant thoughts and reasoning summaries
Sessions are project-specific. Switching directories to a different project switches to that project’s session history.
Resuming Sessions
Resume previous conversations to continue with all prior context restored.From the Command Line
Use the--resume or -r flag when starting Gemini CLI.
From the Interactive Interface
While the CLI is running, use the/resume command to open the Session Browser.
Session Browser Features
Browse Sessions
Browse Sessions
Scroll through a list of past sessions with:
- Session date and timestamp
- Message count
- First user prompt for context
- Session ID
Search Sessions
Search Sessions
Press
/ to enter search mode and filter by:- Session ID
- Conversation content
- Prompts and responses
Sort Sessions
Sort Sessions
Sort sessions by:
- Date (newest/oldest)
- Message count (most/least)
Select Session
Select Session
- Press
Enterto resume the selected session - Press
Escto exit without resuming
Managing Sessions
Keep your history organized and manage disk space.Listing Sessions
View all available sessions for the current project:Deleting Sessions
Remove old or unwanted sessions to free up space.- Command Line
- Session Browser
Delete by index or ID:or
Configuration
Customize session management behavior in yoursettings.json file.
Session Retention
By default, Gemini CLI automatically cleans up old sessions to prevent indefinite growth. Default Policy: Retain sessions for 30 daysConfigure Retention
Edit via/settings or manually in settings.json:
Settings Reference
Master switch for automatic session cleanup.
Duration to keep sessions. Sessions older than this are deleted.Examples:
"24h", "7d", "4w"Maximum number of sessions to retain. Oldest sessions exceeding this count are deleted.Default: Unlimited
Minimum retention period (safety limit). Sessions newer than this are never deleted by automatic cleanup.
Session Limits
Limit the length of individual sessions to control context window size and costs.Maximum number of turns (user and model exchanges) allowed in a single session.Set to
-1 for unlimited (default).Behavior When Limit Reached
- Interactive Mode
- Non-Interactive Mode
The CLI shows an informational message and stops sending requests. You must manually start a new session.
Storage Locations
Session Data
- Linux/macOS
- Windows
Associated Data
- Implementation plans:
~/.gemini/tmp/<project_hash>/plans/ - Task trackers:
~/.gemini/tmp/<project_hash>/tasks/ - Tool outputs:
~/.gemini/tmp/<project_hash>/outputs/ - Activity logs:
~/.gemini/tmp/<project_hash>/logs/
Manual Checkpoints
Beyond automatic session saving, you can create manual conversation checkpoints with tags.Using /chat Commands
Checkpoint Storage
Manual checkpoints are stored separately from automatic sessions:- Linux/macOS
- Windows
Manual
/chat checkpoints are for conversation state only. For file modification checkpoints, see Checkpointing.Export Conversations
Export current conversation to Markdown or JSON:Best Practices
Use Descriptive Tags
When creating manual checkpoints with
/chat save, use descriptive tags like before-refactor or working-auth.Regular Cleanup
Periodically review and delete old sessions to manage disk space, even with automatic cleanup enabled.
Project Isolation
Remember that sessions are project-scoped. Start the CLI from your project directory to access relevant history.
Limit Long Sessions
Set
maxSessionTurns to prevent context windows from becoming too large and expensive.Troubleshooting
Can't find previous session
Can't find previous session
Cause: Sessions are project-specific based on the directory where you run the CLI.Solution: Navigate to the project directory where the session was created, then run
/resume or gemini --resume.Session browser is empty
Session browser is empty
Cause: No sessions exist for the current project.Solution: Ensure you’re in the correct project directory. Sessions created in other directories won’t appear.
Session was auto-deleted
Session was auto-deleted
Cause: Automatic cleanup removed the session based on retention policy.Solution: Check
general.sessionRetention.maxAge and maxCount settings. Increase retention period or disable automatic cleanup with "enabled": false.Resume restores wrong context
Resume restores wrong context
Cause: Multiple projects may share the same hash if directory structure is similar.Solution: Verify you’re in the correct project directory. The project hash is based on the absolute path.
Related Features
Checkpointing
Automatic snapshots before file modifications with
/restoreMemory
Persistent instructional context across sessions
Rewind
Navigate backward through conversation history
Next Steps
Commands Overview
Learn about
/resume, /chat, and /rewind commandsConfiguration
Configure session retention and limits