Session Management
This page introduces MANYOYO's session management mechanism, including session creation, resumption, persistence, and best practices.
Note: Run profiles should be under
runs.<name>in~/.manyoyo/manyoyo.json; use absolute paths forenvFileand map style forenv.
What is a Session
In MANYOYO, a Session refers to:
- A running container instance
- The working state of the AI agent inside the container
- The agent's conversation history and context
Session Lifecycle
Create → Run → Pause/Exit → Resume → Delete
↓ ↓ ↓ ↓ ↓
Container AI Work Container Continue Cleanup
Running Preserved WorkCreating Sessions
Auto-named Sessions
# Auto-generate container name (based on timestamp)
manyoyo run -y c
# Generated name like: my-0204-1430
# View container name
manyoyo psNaming Rule: my-{MMDD}-{HHMM}
- Example:
my-0204-1430means created on Feb 4 at 14:30
Named Sessions
# Create named session (recommended)
manyoyo run -n my-project -y c
# Advantages:
# - Easy to remember
# - Convenient for managing multiple projects
# - Configuration files can use fixed namesCreating Sessions Using Configuration Files
# Method 1: Run configuration (recommended)
cat > ~/.manyoyo/manyoyo.json << 'EOF'
{
"runs": {
"project-a": {
"containerName": "my-project-a",
"envFile": ["/abs/path/anthropic_claudecode.env"],
"yolo": "c"
}
}
}
EOF
manyoyo run -r project-a
# Method 2: Run profile with project path
cat > ~/.manyoyo/manyoyo.json << 'EOF'
{
"runs": {
"project-b": {
"containerName": "my-myproject",
"hostPath": "/abs/path/myproject",
"containerPath": "/abs/path/myproject",
"envFile": ["/abs/path/anthropic_claudecode.env"],
"yolo": "c"
}
}
}
EOF
manyoyo run -r project-bSession Resumption
Exit Prompt
When you exit a container session, the system will prompt:
Container exited, please select an action:
y - Keep container running in background (default)
n - Remove container
1 - Re-enter using the initial command
r - Resume initial command session (agent commands only)
x - Execute a new command
i - Enter interactive shellOption Descriptions
y - Keep Running (Recommended)
# After selecting 'y', container runs in background
# You can resume the session later
# Resume Claude Code session
manyoyo run -n my-project -- -c
# Resume Codex session
manyoyo run -n my-project -- resume --last
# Resume Gemini session
manyoyo run -n my-project -- -rUse Cases:
- Temporarily away, continue work later
- Need to preserve AI conversation history
- Testing not complete, need to continue
n - Remove Container
# After selecting 'n', container is removed
# All data and history are lostUse Cases:
- One-time testing
- Don't need to preserve history
- Want to free resources
1 - Re-enter
# After selecting '1', re-enter using the startup command
# For example, if started with 'manyoyo run -y c'
# Then re-run 'claude --dangerously-skip-permissions'Use Cases:
- AI accidentally exited
- Need to restart AI tool
- Clear current session but keep container
r - Resume Initial Command Session
# After selecting 'r', append the agent resume arg to the initial command
# Example:
# Claude -> -r
# Codex -> resumeUse Cases:
- Initial command is an agent CLI
- Want a fast resume path without manual input
x - Execute New Command
# After selecting 'x', can execute any command
# Prompt to input command
# Example:
x
Enter command to execute: npm testUse Cases:
- Need to run tests
- Check modifications made by AI
- Execute custom scripts
i - Enter Shell
# After selecting 'i', enter /bin/bash
# You can:
$ ls -la # View files
$ git status # Check code
$ npm test # Run tests
$ claude --version # Check tool versionUse Cases:
- Need to manually check
- Debug issues
- Run multiple commands
Agent-specific Resume Commands
Different AI CLI tools have different resume methods:
Claude Code
# Resume last session
manyoyo run -n my-session -- -c
manyoyo run -n my-session -- --continue
# View available sessions
manyoyo run -n my-session -x "claude --list-sessions"Codex
# Resume last session
manyoyo run -n my-session -- resume --last
# Resume specific session
manyoyo run -n my-session -- resume <session-id>
# List all sessions
manyoyo run -n my-session -- listGemini
# Resume session
manyoyo run -n my-session -- -r
manyoyo run -n my-session -- --resume
# Clear session history
manyoyo run -n my-session -- --clearOpenCode
# Resume session
manyoyo run -n my-session -- -c
manyoyo run -n my-session -- --continueSession Persistence
Container Persistence
Container state is managed by Docker/Podman:
# View all sessions (including stopped)
manyoyo ps
docker ps -a | grep my
# Container status
docker ps -a --format "table {{.Names}}\t{{.Status}}"Data Persistence
1. Working Directory Mount
# Mount current directory by default
manyoyo run -y c # Current directory auto-mounted
# Specify working directory
manyoyo run --hp /path/to/project -y c
# Code modifications are saved on host2. Additional Data Mount
# Mount data directory
manyoyo run -v "/data:/workspace/data" -y c
# Mount configuration files
manyoyo run -v "~/.gitconfig:/root/.gitconfig:ro" -y c3. Use Volumes (Recommended)
# Create persistent volume
docker volume create myproject-data
# Mount volume
manyoyo run -v "myproject-data:/workspace/data" -y c
# Data persists after container removalAI Conversation History Persistence
Different AI tools store history in different locations:
Claude Code
# History stored inside container
# Location: ~/.claude/sessions/
# Mount session directory (optional)
manyoyo run -v "~/.claude:/root/.claude" -y cCodex
# History stored inside container
# Location: ~/.codex/sessions/
# Mount session directory
manyoyo run -v "~/.codex:/root/.codex" -y cMulti-session Management
Parallel Sessions
# Project A
manyoyo run -n project-a --hp ~/projects/a -y c
# Project B
manyoyo run -n project-b --hp ~/projects/b -y c
# Project C
manyoyo run -n project-c --hp ~/projects/c -y c
# View all sessions
manyoyo psSession Switching
# Work in project A
manyoyo run -n project-a -- -c
# Switch to project B
manyoyo run -n project-b -- -c
# Switch to project C
manyoyo run -n project-c -- -cSession Isolation
Each session is completely independent:
- Independent file system
- Independent environment variables
- Independent AI conversation history
- Independent process space
Session Cleanup
Manual Cleanup
# Remove single session
manyoyo rm my-session
manyoyo rm my-session
# Or use Docker command
docker rm -f my-sessionAutomatic Cleanup
# One-time session (auto-remove after exit)
manyoyo run -n temp --rm-on-exit -y c
# Use cases:
# - Temporary testing
# - Quick verification
# - Don't need to preserve historyBatch Cleanup
# Clean up all stopped MANYOYO containers
docker ps -a | grep my | grep Exited | awk '{print $1}' | xargs docker rm
# Clean up all MANYOYO containers (dangerous!)
docker ps -a | grep my | awk '{print $1}' | xargs docker rm -fSession Monitoring
View Session Status
# List all MANYOYO sessions
manyoyo ps
# Detailed status
docker ps -a --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
# Resource usage
docker stats $(docker ps -q --filter "name=my")View Session Logs
# View container logs
docker logs my-session
# Real-time logs
docker logs -f my-session
# Last 100 lines
docker logs --tail 100 my-sessionEnter Running Session
# Enter shell to check
manyoyo run -n my-session -x /bin/bash
# View processes
$ ps aux
# View files
$ ls -la
# View environment variables
$ env | grep ANTHROPICBest Practices
1. Naming Conventions
# Name by project
my-webapp
my-api
my-mobile
# Name by function
my-dev
my-test
my-debug
# Name by time (automatic)
my-0204-14302. Configuration File Management
# Create configuration for each project
~/.manyoyo/manyoyo.json
└── runs
├── webapp
├── api
├── mobile
└── debug
# Quick start
manyoyo run -r webapp
manyoyo run -r api
manyoyo run -r mobile3. Data Backup
# Export container configuration
docker inspect my-session > my-session.json
# Backup mounted data
tar -czf backup.tar.gz ~/projects/myproject
# Backup AI history (optional)
docker cp my-session:/root/.claude ./claude-backup4. Regular Cleanup
# Weekly cleanup script
cat > ~/cleanup-manyoyo.sh << 'EOF'
#!/bin/bash
# Clean up stopped containers older than 7 days
docker ps -a --filter "name=my" --filter "status=exited" \
--format "{{.ID}} {{.CreatedAt}}" | \
awk '{if ($2 < systime() - 604800) print $1}' | \
xargs -r docker rm
# Clean up dangling images
docker image prune -f
EOF
chmod +x ~/cleanup-manyoyo.sh5. Session Templates
# Create session template
cat > ~/.manyoyo/manyoyo.json << 'EOF'
{
"runs": {
"template": {
"containerName": "my-template",
"envFile": ["/abs/path/base.env", "/abs/path/secrets.env"],
"volumes": [
"~/.ssh:/root/.ssh:ro",
"~/.gitconfig:/root/.gitconfig:ro"
],
"env": {
"TZ": "Asia/Shanghai"
}
}
}
}
EOF
# Create new session based on template
manyoyo run -r template
# Copy runs.template to runs.newproject and update containerNameAdvanced Tips
Session Snapshots
# Commit container as image (save current state)
docker commit my-session my-session:snapshot-$(date +%Y%m%d)
# Create new session from snapshot
docker run -it my-session:snapshot-20240204Session Export/Import
# Export session
docker export my-session > my-session.tar
# Import to another machine
cat my-session.tar | docker import - my-session:importedSession Sharing
# Multi-person collaboration (same container)
# Person A creates session
manyoyo run -n shared-session -y c
# Person B enters same session
manyoyo run -n shared-session -x /bin/bash
# Note: Not recommended for multiple people to use AI simultaneouslyTroubleshooting
Session Cannot Resume
Problem: Container does not exist prompt
Solution:
# Check if container exists
manyoyo ps
docker ps -a | grep my-session
# If not exists, create new session
manyoyo run -n my-session -y cAI History Lost
Problem: After resuming session, AI doesn't remember previous conversations
Solution:
# Check if container is newly created
docker ps -a --format "{{.Names}}\t{{.CreatedAt}}"
# Mount session directory (when creating next time)
manyoyo run -v "~/.claude:/root/.claude" -n my-session -y cContainer Cannot Start
Problem: Session fails to start
Solution:
# View container logs
docker logs my-session
# Remove and recreate
manyoyo rm my-session
manyoyo run -n my-session -y cIntegration with Skills Marketplace
If Skills Marketplace is installed, you can get more powerful session management features:
# List all sessions (including cloud)
claude --list-sessions
# Resume cloud session
claude --resume-session <session-id>
# Sync sessions to cloud
claude --sync-sessionsRelated Documentation
- Basic Usage - Learn basic commands
- AI Agents - Learn about each agent's session management
- Configuration Examples - View configuration examples
- Container Modes - Learn about container management