Session Management¶
Save, restore, and manage your conversation sessions with SQLite-based persistence.
Overview¶
Victor stores conversation sessions in the project database (.victor/project.db), providing:
- Fast queries with indexed tables
- Single source of truth (no JSON file duplication)
- Interactive session browser with visual selection
- Parallel session support (multiple terminals, different sessions)
- Combined operations (resume + switch model in one command)
- Project-level storage (sessions stored per project)
Parallel Sessions¶
Victor supports multiple terminal sessions working simultaneously with unique session IDs:
Terminal 1 (DevOps):
victor chat "Setup CI/CD pipeline"
/save "CI/CD Pipeline" # Creates session: 20250107_100000
# ... continue working ...
/save # UPDATES 20250107_100000 (not create new!)
Terminal 2 (Testing):
victor chat "Write unit tests"
/save "Unit Tests" # Creates session: 20250107_100100
# ... continue working ...
/save # UPDATES 20250107_100100 (not create new!)
Switch Between Sessions:
# In Terminal 1, switch to testing session
/resume 20250107_100100
# ... work on tests ...
/save # Updates 20250107_100100
# Or combine resume + switch
/switch ollama:qwen2.5-coder:7b --resume 20250107_100100
Key Behavior:
- /save updates the active session (the one you resumed)
- /save --new creates a new session (ignores active session)
- /resume <id> sets the active session
- /compact preserves the active session ID
Database Schema¶
Sessions are stored in two tables:
-- Sessions table: metadata and conversation state
CREATE TABLE sessions (
id TEXT PRIMARY KEY, -- Session ID (timestamp-based)
name TEXT, -- Session title
provider TEXT, -- Provider name
model TEXT, -- Model name
profile TEXT, -- Profile used
data TEXT, -- JSON: full session data
created_at TEXT, -- ISO timestamp
updated_at TEXT -- ISO timestamp
);
-- Messages table: individual messages
CREATE TABLE messages (
id INTEGER PRIMARY KEY AUTOINCREMENT,
session_id TEXT, -- Foreign key to sessions.id
role TEXT, -- 'user', 'assistant', 'system'
content TEXT, -- Message content
tool_calls TEXT, -- JSON: tool call data (optional)
created_at TEXT, -- ISO timestamp
FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
);
Commands¶
/save - Save Session¶
Save your current conversation to SQLite.
/save # Update active session or create new
/save "Refactoring Authentication" # Update active with new title
/save --new # Always create new session
/save --new "New Topic" # Create new with custom title
Behavior:
- First save: Creates new session with auto-generated ID
- Subsequent saves: Updates the active session (after /resume)
- With --new: Always creates a new session (for parallel work)
Example Output:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Session Saved โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ Updated session 20250107_153045! โ
โ โ
โ Session ID: 20250107_153045 โ
โ Database: /project/.victor/project.db โ
โ Title: Refactoring Authentication โ
โ โ
โ Use '/resume 20250107_153045' to โ
โ restore this session โ
โ Use '/save --new' to create a new โ
โ session โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
/sessions - List Sessions¶
List saved sessions with metadata.
Example Output:
โโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโคโโโโโโโโโโโโโคโโโโโโโโโโ
โ ID โ Title โ Model โ Provider โ Messages โ Created โ
โ โโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโชโโโโโโโโโโโโโชโโโโโโโโโโฃ
โ 20250107โฆ โ Refactoring Authenticationโฆ โ claude-sonnet-4-2 โ anthropic โ 42 โ 14:30 โ
โ 20250107โฆ โ API Testing โ gpt-4 โ openai โ 18 โ 12:15 โ
โ 20250106โฆ โ Code Review โ qwen2.5-coder:7b โ ollama โ 67 โ 09:45 โ
โโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโโโดโโโโโโโโโโ
Use '/resume <session_id>' to restore a session
Or '/switch <model> --resume <session_id>' to resume and switch
/resume - Restore Session¶
Restore a previously saved session.
Interactive Mode:
Shows a numbered list of recent sessions. Enter a number to select.
โโโโโโคโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโคโโโโโโโโโโโ
โ # โ ID โ Title โ Model โ Messages โ Date โ
โ โโโโโชโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโชโโโโโโโโโโโฃ
โ 1 โ 20250107โฆ โ Refactoring Authentication โ claude-sonnet-4-2 โ 42 โ 14:30 โ
โ 2 โ 20250107โฆ โ API Testing โ gpt-4 โ 18 โ 12:15 โ
โ 3 โ 20250106โฆ โ Code Review โ qwen2.5-coder:7b โ 67 โ 09:45 โ
โโโโโโงโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโงโโโโโโโโโโโ
Enter session number to resume (1-3)
Or use: /resume <session_id>
Restored Session:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Session Resumed โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ Session restored from SQLite! โ
โ โ
โ ID: 20250107_153045 โ
โ Title: Refactoring Authentication โ
โ Model: claude-sonnet-4-20250514 โ
โ Provider: anthropic โ
โ Messages: 42 โ
โ Created: 2025-01-07T14:30:45 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
/switch - Switch Model/Provider¶
Switch models or providers, optionally resuming a session first.
/switch # Show current model
/switch claude-opus-4-20250514 # Switch model only
/switch anthropic:claude-opus-4 # Switch provider and model
/switch --resume # Resume last session, then show current
/switch --resume 20250107_153045 # Resume specific session, show current
/switch claude-opus-4 --resume # Resume last, then switch to this model
/switch ollama:qwen2.5-coder:7b --resume 20250107_153045 # Combined
Examples:
-
Switch model only:
-
Switch provider and model:
-
Resume then switch:
/compact - Reduce Context Size¶
Compress conversation history to reduce token usage.
/compact # Simple truncation (keeps last 6 messages)
/compact --smart # AI-powered summarization
/compact --smart --keep 10 # Keep last 10 messages + summary
Smart Compaction Example:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Smart Compaction Complete โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ Compacted 42 messages to 8. โ
โ โ
โ Summary: โ
โ The user requested help refactoring โ
โ the authentication module. We: โ
โ 1. Analyzed the current auth flow โ
โ 2. Identified security issues โ
โ 3. Implemented JWT token validation โ
โ 4. Added unit tests โ
โ 5. Updated documentation โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
CLI Commands¶
Victor also provides CLI commands for managing sessions outside of the chat interface:
victor sessions list - List Sessions¶
List saved sessions from the command line.
victor sessions list # List last 10 sessions
victor sessions list --limit 20 # List last 20 sessions
victor sessions list --all # List all sessions (no limit)
victor sessions list --json # Output as JSON
Examples:
# List recent sessions
$ victor sessions list
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ Saved Sessions (last 5) โ
โโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโค
โ Session ID โ Title โ Model โ Provider โ ... โ
โโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโค
โ myproj-9Kx โ CI/CD Pipeline โ claude-... โ anthro.. โ ... โ
โ myproj-8Z3 โ Unit Tests โ gpt-4 โ openai โ ... โ
โฐโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโฏ
# List all sessions (useful when you have many)
$ victor sessions list --all
# Output as JSON for scripting
$ victor sessions list --json | jq '.[] | .title'
victor sessions show - Show Session Details¶
View detailed information about a specific session.
victor sessions show <session_id> # Show formatted details
victor sessions show <session_id> --json # Output as JSON
Example:
$ victor sessions show myproj-9Kx7Z2
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ Session Details โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Session ID: myproj-9Kx7Z2 โ
โ Title: CI/CD Pipeline Setup โ
โ Model: claude-sonnet-4-20250514 โ
โ Provider: anthropic โ
โ Profile: default โ
โ Messages: 12 โ
โ Created: 2025-01-07T14:30:45 โ
โ Updated: 2025-01-07T15:45:22 โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
victor sessions search - Search Sessions¶
Search for sessions by title or content.
victor sessions search <query> # Search sessions
victor sessions search CI/CD --limit 5 # Limit results
victor sessions search test --json # Output as JSON
Example:
$ victor sessions search "authentication"
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ Sessions matching 'authentication' โ
โโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโค
โ Session ID โ Title โ Model โ Provider โ ... โ
โโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโค
โ myproj-7A2 โ Auth Refactoring โ claude-... โ anthro.. โ ... โ
โ myproj-5B9 โ Login Bug Fix โ gpt-4 โ openai โ ... โ
โฐโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโฏ
victor sessions clear - Clear Sessions¶
Delete sessions from the database. Use with caution!
# Clear all sessions (with confirmation prompt)
victor sessions clear
# Clear all sessions (skip confirmation)
victor sessions clear --yes
victor sessions clear --all --yes
# Clear sessions matching a prefix (min 6 characters)
victor sessions clear myproj-9Kx
# Clear sessions by prefix (skip confirmation)
victor sessions clear myproj-9Kx --yes
Safety Features:
- Confirmation prompt: Prevents accidental deletion
- Prefix filtering: Delete only sessions matching a pattern
- Minimum prefix length: 6 characters required to avoid accidental broad matches
- Dry-run feedback: Shows how many sessions will be deleted
Examples:
-
Clear all sessions with confirmation:
-
Clear sessions by prefix:
-
Skip confirmation for automation:
Use Cases:
- Clean up test sessions: victor sessions clear test-1234 --yes
- Remove old sessions: victor sessions clear myproj-Jan --yes
- Start fresh: victor sessions clear --yes
victor sessions delete - Delete Specific Session¶
Delete a single session by ID.
victor sessions delete <session_id> # Delete with confirmation
victor sessions delete <session_id> --yes # Skip confirmation
Example:
$ victor sessions delete myproj-9Kx7Z2
Delete session myproj-9Kx7Z2? [y/N]: y
โ Deleted session: myproj-9Kx7Z2
victor sessions export - Export Sessions¶
Export all sessions to a JSON file.
victor sessions export # Auto-generated filename
victor sessions export --output sessions.json # Custom filename
victor sessions export --no-pretty # Minified JSON
Example:
Advanced Usage¶
Conversation State Machine¶
When you save a session, Victor preserves the conversation state machine, including:
- Current stage (plan, explore, build, etc.)
- Mode transitions
- Task progress
- Tool selection statistics
This means when you resume, the conversation state is fully restored.
Cross-Model Workflows¶
Leverage different model strengths in a single session:
# 1. Start with Claude for complex reasoning
victor chat --provider anthropic "Design a REST API"
# ... work on design ...
# 2. Save the session
/save API Design
# 3. Resume with GPT-4 for implementation
/switch gpt-4 --resume
# 4. Finish with local model for privacy
/switch ollama:qwen2.5-coder:7b
Session Organization¶
Use descriptive titles to organize sessions:
/save "Authentication Refactoring - Phase 1"
/save "Bug Fix: Race condition in payment processing"
/save "Feature: User profile management"
Then use /sessions to browse and find what you need.
Database Management¶
Location¶
Sessions are stored in the project database:
Direct SQL Access¶
You can query sessions directly using SQLite:
# List all sessions
sqlite3 .victor/project.db "SELECT id, name, model, created_at FROM sessions ORDER BY created_at DESC;"
# Count messages per session
sqlite3 .victor/project.db "
SELECT s.name, COUNT(m.id) as message_count
FROM sessions s
LEFT JOIN messages m ON s.id = m.session_id
GROUP BY s.id
ORDER BY message_count DESC;
"
# Search sessions by title
sqlite3 .victor/project.db "
SELECT id, name, model, created_at
FROM sessions
WHERE name LIKE '%authentication%'
ORDER BY created_at DESC;
"
Backup and Restore¶
# Backup sessions
cp .victor/project.db .victor/project.db.backup
# Restore sessions
cp .victor/project.db.backup .victor/project.db
Migration from JSON (Optional)¶
If you have existing JSON sessions in ~/.victor/sessions/, you can still access them. The system is backward compatible.
To migrate JSON sessions to SQLite (manual process):
-
List JSON sessions:
-
For each JSON session, manually:
- Load the JSON file
- Extract conversation, model, provider data
- Use/saveto create a new SQLite session
- Copy conversation content from JSON
A migration utility may be added in a future release.
Troubleshooting¶
Session not found¶
Error: Session not found: 20250107_153045
Solutions:
1. Use /sessions to list available sessions
2. Check the session ID is correct
3. Verify you're in the correct project directory
Database locked¶
Error: database is locked
Solutions:
1. Close other Victor instances
2. Check for background processes: ps aux | grep victor
3. Ensure no other tools are accessing .victor/project.db
Empty sessions list¶
Error: /sessions shows "No saved sessions found"
Solutions:
1. Save a session first: /save My Session
2. Check database exists: ls .victor/project.db
3. Verify database tables: sqlite3 .victor/project.db ".tables"
Conversation state not restored¶
Issue: Resumed session but conversation state lost
Cause: Session saved before conversation state machine was implemented
Solution: Save new sessions will include conversation state
Best Practices¶
-
Save frequently: After completing significant work
-
Use descriptive titles: Include context and status
-
Leverage model switching: Use different models for different phases
-
Compact long sessions: Reduce context before resuming
-
Organize by task: Use consistent naming
API Reference¶
Python API¶
You can also use session persistence programmatically:
from victor.agent.sqlite_session_persistence import get_sqlite_session_persistence
# Get persistence instance
persistence = get_sqlite_session_persistence()
# Save session
session_id = persistence.save_session(
conversation=agent.conversation,
model=agent.model,
provider=agent.provider_name,
title="My Session",
conversation_state=agent.conversation_state,
)
# Load session
session_data = persistence.load_session(session_id)
# List sessions
sessions = persistence.list_sessions(limit=10)
# Search sessions
sessions = persistence.search_sessions("authentication", limit=5)
# Delete session
persistence.delete_session(session_id)
See also:
- CLI Reference - All slash commands
- Provider Switching - Switching providers
- Architecture Deep Dive - Database design