Always start troubleshooting with the health check:
sam health
This command provides:
sam setup
Validates:
Error: Missing or invalid OpenAI API key
Solutions:
# Option 1: Run setup wizard sam onboard # Option 2: Manual configuration echo "OPENAI_API_KEY=sk-your-key-here" >> .env source .env # Option 3: Environment variable export OPENAI_API_KEY="sk-your-key-here"
Verification:
sam setup # Should show API key as valid
Error: Missing encryption key for secure storage
Solutions:
# Generate new encryption key sam key generate # Or manually add to .env echo "SAM_FERNET_KEY=your-generated-key" >> .env
Warning: System keyring unavailable, falling back to environment variables
Solutions:
# Install keyring dependencies pip install keyring keyrings.alt # Linux # or pip install keyring # macOS/Windows # Or use environment variable fallback sam key import # Will use legacy method
Symptoms:
Solutions:
# Verify private key format (should be base58) # Solana private keys are 64-character base58 strings # Check keyring availability sam key import # Will show detailed error # Use legacy method if keyring fails # Follow prompts to use environment variable method
Symptoms:
Solutions:
# Verify wallet address sam # Start interactive mode /wallet # Shows current wallet address # Re-import private key sam key import # Check configuration sam setup
Symptoms:
Solutions:
# Verify API key curl -H "Authorization: Bearer $OPENAI_API_KEY" \ https://api.openai.com/v1/models # Check API key format (should start with 'sk-') echo $OPENAI_API_KEY | head -c 10 # Should show 'sk-' # Verify API credits # Visit https://platform.openai.com/api-keys
Symptoms:
Solutions:
# Test RPC endpoint curl -X POST -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"getVersion"}' \ $SAM_SOLANA_RPC_URL # Try different RPC endpoints export SAM_SOLANA_RPC_URL="https://api.mainnet-beta.solana.com" # Check network connectivity ping api.mainnet-beta.solana.com
Symptoms:
Solutions:
# Verify API key export BRAVE_API_KEY="your-brave-api-key" # Test API connectivity curl "https://api.search.brave.com/res/v1/web/search?q=test&key=$BRAVE_API_KEY"
Symptoms:
Solutions:
# Transactions are time-sensitive, retry immediately # This is normal for high network congestion # Use faster RPC endpoint export SAM_SOLANA_RPC_URL="https://fast-rpc-endpoint.com" # Reduce slippage for faster execution export DEFAULT_SLIPPAGE=1
Symptoms:
Solutions:
# Check balance sam "check my balance" # Verify wallet has enough SOL for transaction + fees # Minimum 0.000005 SOL for transaction fees # Add funds to wallet # Transfer SOL from exchange or another wallet
Symptoms:
Solutions:
# Increase slippage for volatile tokens "buy 0.01 SOL of TOKEN with 10% slippage" # Decrease slippage for stable pairs "swap 1 SOL to USDC with 0.5% slippage" # Set global default export DEFAULT_SLIPPAGE=5
Symptoms:
Solutions:
# List available tools sam tools # Check agent initialization sam health # Verify tools loaded # Restart agent sam # Fresh session
Symptoms:
Solutions:
# Wait before retrying (rate limits reset every minute) sleep 60 # Check rate limit status sam health # Reduce request frequency export RATE_LIMITING_ENABLED=true
Symptoms:
Solutions:
# Check network connectivity ping api.mainnet-beta.solana.com # Try different RPC endpoint export SAM_SOLANA_RPC_URL="https://backup-rpc.com" # Increase timeout (if configurable) export HTTP_TIMEOUT=120
Symptoms:
Solutions:
# Clear conversation context sam /clear-context # Compact conversation history /compact # Check memory usage sam health # Shows memory stats # Restart agent for fresh session sam
Symptoms:
Solutions:
# Run maintenance sam maintenance # Check database integrity sam health # Backup and restore (if corruption) cp .sam/sam_memory.db .sam/backup.db sam # Creates new database
Symptoms:
Solutions:
# Verify encryption key matches stored data echo $SAM_FERNET_KEY # Re-import private key with current key sam key import # Generate new key and reconfigure sam key generate sam key import
Symptoms:
Solutions:
# Fix file permissions chmod 600 .env chmod 700 .sam/ # Run with proper user permissions # Don't run as root for security
Enable detailed logging for investigation:
# Debug mode sam --log-level DEBUG # Check logs tail -f sam.log # Verbose health check sam health --verbose
# Test all API endpoints curl -I https://api.openai.com/v1/models curl -I $SAM_SOLANA_RPC_URL curl -I https://api.search.brave.com/ # DNS resolution nslookup api.mainnet-beta.solana.com # Network latency ping -c 3 api.mainnet-beta.solana.com
# Validate all settings sam setup --verbose # Check environment variables env | grep -E "(OPENAI|SAM_|BRAVE)" # Verify .env file syntax python -c "import dotenv; dotenv.load_dotenv('.env'); print('Valid')"
# Check database size ls -lh .sam/sam_memory.db # Verify database integrity sqlite3 .sam/sam_memory.db "PRAGMA integrity_check;" # View recent sessions sqlite3 .sam/sam_memory.db "SELECT COUNT(*) FROM sessions;" # Clear old data sam maintenance
Symptoms:
Recovery:
# Backup current state cp -r .sam .sam.backup # Reinitialize sam onboard # Fresh setup # Restore from backup if needed cp .sam.backup/* .sam/
Symptoms:
Immediate Actions:
Symptoms:
Recovery:
# Isolate system # Change all credentials # Reinstall from trusted source # Verify file integrity
Health Check First
sam health # Always run this first
Gather Information
sam setup # Configuration status sam --log-level DEBUG # Enable debug logging
Community Support
When reporting issues, include:
# System information python --version uv --version uname -a # SAM version and status sam --version # If available sam health # Configuration (redact sensitive data) sam setup # Error logs tail -50 sam.log
# Complete reset (CAUTION: loses all data) rm -rf .sam/ rm .env sam onboard # Fresh start
# Reset specific components sam key generate # New encryption key sam key import # Re-import private key sam maintenance # Database cleanup
# Create backup tar -czf sam_backup_$(date +%Y%m%d).tar.gz .sam/ .env # Restore from backup tar -xzf sam_backup_20231201.tar.gz
sam health
daily.env
and .sam/
backed up