agentlib-memory 0.1.0

Advanced memory providers and history management for AgentLib
Documentation

agentlib-memory

Advanced memory management for AI agents. This crate provides various implementations of the MemoryProvider trait to manage conversation history of varying lengths and complexities.

Providers

  • BufferMemory: Simple in-memory storage with optional message limits.
  • SlidingWindowMemory: Maintains a fixed number of recent conversation turns while respecting a token budget.
  • SummarizingMemory: Uses an LLM to compress older parts of the conversation into a summary once a window threshold is reached.
  • CompositeMemory: Chains multiple memory providers together (e.g., a local buffer followed by a vector database).

Usage

use agentlib_memory::BufferMemory;
use std::sync::Arc;

let memory = Arc::new(BufferMemory::new(50)); // Store last 50 messages

Implementation Details

The memory system handles:

  • Token estimation for messages.
  • Session isolation.
  • Metadata tagging for indexed retrieval.