adk-memory 0.2.0

Semantic memory and search for Rust Agent Development Kit (ADK-Rust) agents
Documentation

adk-memory

Semantic memory and search for Rust Agent Development Kit (ADK-Rust) agents.

Crates.io Documentation License

Overview

adk-memory provides long-term memory capabilities for the Rust Agent Development Kit (ADK-Rust):

  • InMemoryMemoryService - Simple in-memory memory storage
  • MemoryService - Trait for custom storage backends
  • Semantic Search - Query memories by content similarity
  • Memory Entries - Structured memory with content and metadata

Installation

[dependencies]
adk-memory = "0.2.0"

Or use the meta-crate:

[dependencies]
adk-rust = { version = "0.2.0", features = ["memory"] }

Quick Start

use adk_memory::{InMemoryMemoryService, MemoryService, MemoryEntry, SearchRequest};
use adk_core::Content;
use chrono::Utc;

// Create memory service
let service = InMemoryMemoryService::new();

// Add memories from a session
let entries = vec![
    MemoryEntry {
        content: Content::new("user").with_text("User prefers dark mode"),
        author: "system".to_string(),
        timestamp: Utc::now(),
    },
];

service.add_session(
    "my_app",
    "user_123",
    "session_456",
    entries,
).await?;

// Search memories
let response = service.search(SearchRequest {
    query: "what theme does the user like?".to_string(),
    user_id: "user_123".to_string(),
    app_name: "my_app".to_string(),
}).await?;

for memory in response.memories {
    println!("Found: {:?}", memory.content);
}

Memory Entry Structure

pub struct MemoryEntry {
    pub content: Content,           // Message content with parts
    pub author: String,             // Who created this memory
    pub timestamp: DateTime<Utc>,   // When it was created
}

MemoryService Trait

#[async_trait]
pub trait MemoryService: Send + Sync {
    async fn add_session(
        &self,
        app_name: &str,
        user_id: &str,
        session_id: &str,
        entries: Vec<MemoryEntry>,
    ) -> Result<()>;
    
    async fn search(&self, req: SearchRequest) -> Result<SearchResponse>;
}

Features

  • Per-user memory isolation
  • Simple keyword-based search
  • Timestamp tracking
  • Pluggable storage backends

Related Crates

License

Apache-2.0

Part of ADK-Rust

This crate is part of the ADK-Rust framework for building AI agents in Rust.