Skip to main content
The Memory System enables switchAILocal to learn from every routing decision, building a persistent knowledge base of user preferences, provider quirks, and performance patterns.

Overview

The Memory System stores:
  • Routing History: Every decision with outcomes and latency
  • User Preferences: Learned model preferences per API key
  • Provider Quirks: Known issues and workarounds
  • Analytics: Performance trends and success rates
Memory data is stored in ~/.switchailocal/memory/ and can grow over time. Configure retention policies to manage disk usage.

Quick Start

Initialize Memory System

Initialize the memory system before first use:
Output:

Enable in Configuration

Add to your config.yaml:
config.yaml

CLI Commands

The Memory System provides a comprehensive CLI for management:
Check memory system health and disk usage:
Example Output:

Directory Structure

The memory system creates the following structure:

Routing Decision Schema

Each routing decision is stored in JSONL format:

User Preferences

Preferences are learned automatically based on routing history:
1

Model Preferences

Most frequently selected models for each intent category
2

Provider Bias

Relative preference scores based on success rates and user behavior
3

Custom Rules

Detected patterns like β€œalways use local models for security queries”
Preference Schema:

Configuration Options

Fine-tune memory system behavior in config.yaml:
config.yaml

Privacy Considerations

By default, the memory system stores routing metadata only, not request/response content.

What is Stored

  • Hashed API keys (SHA-256)
  • Model names and intents
  • Routing tiers and confidence scores
  • Latency and performance metrics
  • Success/failure outcomes

Configuration for Privacy

config.yaml

Disk Usage Management

The memory system automatically manages disk usage:

Automatic Cleanup

  • Daily rotation: Logs are rotated daily and compressed
  • Retention policy: Old data is deleted after configured retention period
  • Size limits: Logs are rotated when they exceed max size

Manual Cleanup

Monitoring & Analytics

Statistics Query

Memory statistics are available via the management API:
Example Response:

Weekly Reports

When weekly-reports: true, the system generates performance summaries:
analytics/weekly-summary.json

Troubleshooting

Error: Memory system not initializedSolution:
Error: Permission denied: /Users/user/.switchailocal/memorySolution:
Solutions:
  1. Reduce retention period:
  2. Enable compression:
  3. Disable content storage:
Check:
  1. Feedback collection is enabled:
  2. Sufficient history exists (minimum ~100 decisions)
  3. API key hash is consistent

Best Practices

1

Enable from Day One

Initialize memory system before production deployment to start learning immediately.
2

Regular Backups

Export memory data regularly:
3

Monitor Disk Usage

Check memory status weekly:
4

Set Appropriate Retention

Balance learning vs disk usage:
  • Development: 30 days
  • Production: 90 days
  • Analytics: 180 days
5

Review Preferences Periodically

Check learned preferences to ensure they align with expectations:

Next Steps

Cortex Router

Learn about intelligent routing that uses memory data

Heartbeat Monitoring

Configure health checks and monitoring