Memory handling

The Lillo Agent Memory System provides a multi-layered approach to state management and data persistence, combining short-term state tracking with long-term data storage.

Memory Architecture

1. State Management Layer

The state management system handles temporary agent states and creation flows:

interface AgentCreationState {
  userId: number;
  step: AgentCreationStep;
  data: {
    bioField?: BioFieldState;
    socialsField?: SocialsFieldState;
    cryptoField?: CryptoFieldState;
  };
  lastUpdated: number;
  isActive: boolean;
}

Key features:

  • TTL-based state expiration (24 hours)

  • State progression tracking

  • Multi-step process management

  • Automatic cleanup

2. Key-Value Store

The KV store provides fast access to frequently used data:

Use cases:

  • User session data

  • Agent configuration caching

  • Temporary state storage

  • Quick-access data

3. Persistent Storage

Long-term data storage in PostgreSQL:

Memory Types

1. Short-Term Memory

  • State Tracking

  • Session Data

2. Long-Term Memory

  • Chat History

  • Content History

Memory Operations

1. State Management

2. History Management

3. User Data Management

Best Practices

  1. State Management

    • Clear states after completion

    • Handle state transitions gracefully

    • Implement proper error recovery

    • Use appropriate TTLs

  2. Data Persistence

    • Cache frequently accessed data

    • Implement proper invalidation

    • Use transactions for consistency

    • Handle concurrent access

  3. Memory Cleanup

    • Regular cache invalidation

    • State cleanup on completion

    • History pruning strategies

    • Error state recovery

Example Usage

Last updated