-
Notifications
You must be signed in to change notification settings - Fork 0
Session Management
Sessions allow you to organize, persist, and resume conversations with full history.
# Create or resume a named session
REDIS_ENABLED=true pnpm start --session my-project
# With web streaming
REDIS_ENABLED=true WEB_STREAM_ENABLED=true pnpm start --session frontend-workWithout a --session flag, a unique session ID is automatically generated:
REDIS_ENABLED=true pnpm start
# Creates: session-1734782567890-a3f8k2Use the same session name to continue a previous conversation:
pnpm start --session my-projectThe web UI sidebar (http://localhost:3000) displays all available sessions. Click on any session to view its history and copy its name for CLI resumption.
Run different sessions simultaneously in separate terminals:
# Terminal 1
pnpm start --session frontend-ui
# Terminal 2
pnpm start --session backend-api
# Terminal 3
pnpm start --session researchEach session maintains independent conversation history and streams.
pnpm start --session <name>Set a default session name in config.json:
{
"redis": {
"enabled": true,
"sessionName": "my-default-session"
}
}REDIS_SESSION_NAME=temp-session pnpm startPriority: CLI flag > Environment variable > Config file
-
Location: Redis List at
session:{sessionName}:messages - Format: JSON-serialized message objects
- Content: Full conversation history in chronological order
-
Location: Redis Hash at
session:{sessionName}:metadata - Contains: Session name, message count, timestamps, activity info
- Purpose: Enables session listing and sorting in web UI
-
Channel:
ai-chat:stream:{sessionName} - Purpose: Session-specific pub/sub for web streaming
- Behavior: Each session streams independently to its own channel
Configure automatic session expiration:
{
"redis": {
"ttl": 86400 // 24 hours in seconds
}
}Or via environment:
REDIS_TTL=86400 pnpm startSessions expire after the specified period of inactivity.
Sessions are managed through abstracted storage layers:
Abstract class for message storage with implementations:
-
RedisMessageHistory- Persistent Redis storage -
InMemoryMessageHistory- Non-persistent memory storage
Abstract class for session metadata with implementations:
-
RedisSessionStore- Redis Hash storage - Extensible to PostgreSQL, MongoDB, etc.
The /shared directory contains storage abstractions used by both CLI and web app, ensuring consistent session management across platforms.
- Web Streaming - Setting up real-time browser streaming
- Project Structure - Understanding the abstraction layers