Skip to main content

Module memory

Module memory 

Source
Expand description

Memory system

Layered architecture, each with distinct responsibilities:

LayerImplementationScope
Short-term context[compression::ContextManager]Within a single execute() call
Thread stateCheckpointer / FileCheckpointerCross-process recovery of the same thread
Conversation historyConversationStore / SqliteConversationStoreTranscript projection, history browsing, multi-user isolation
Long-term memoryStore / FileStore / SqliteStoreCross-session, cross-user sharing

§Thread state persistence (Checkpointer)

use echo_core::error::Result;
use echo_state::memory::checkpointer::FileCheckpointer;
use std::sync::Arc;

let cp = Arc::new(FileCheckpointer::new("~/.echo-agent/checkpoints.json")?);
// Wire `cp` into your own agent/runtime layer, or use it through the `echo_agent` façade.
let _ = cp;

§Conversation persistence (ConversationStore)

use echo_core::error::Result;
use echo_state::memory::conversation::{ConversationStore, NewConversation};
let conv = store.create_conversation(NewConversation {
    conversation_id: "conv-001".to_string(),
    user_id: "default".to_string(),
    agent_type: None,
    title: Some("Rust discussion".to_string()),
}).await?;
store.save_messages("conv-001", &[/* messages */]).await?;
let msgs = store.get_messages("conv-001").await?;

§Long-term KV storage (Store)

use echo_core::error::Result;
use echo_state::memory::store::{FileStore, Store};
use std::sync::Arc;

let store = Arc::new(FileStore::new("~/.echo-agent/store.json")?);
store.put(&["alice", "memories"], "pref-001", serde_json::json!({
    "content": "User prefers dark theme",
    "importance": 8
})).await?;
let items = store.search(&["alice", "memories"], "theme", 3).await?;

Re-exports§

pub use checkpointer::Checkpointer as ThreadStore;
pub use checkpointer::Checkpoint;
pub use checkpointer::Checkpointer;
pub use checkpointer::FileCheckpointer;
pub use checkpointer::InMemoryCheckpointer;
pub use checkpointer::ThreadState;
pub use conversation::Conversation;
pub use conversation::ConversationFilter;
pub use conversation::ConversationMeta;
pub use conversation::ConversationStore;
pub use conversation::NewConversation;
pub use conversation::StoredMessage;
pub use conversation::project_message;
pub use conversation::project_messages;
pub use embedder::Embedder;
pub use embedder::HttpEmbedder;
pub use embedding_store::EmbeddingStore;
pub use snapshot::SnapshotManager;
pub use snapshot::SnapshotPolicy;
pub use snapshot::StateSnapshot;
pub use sqlite_conversation::SqliteConversationStore;
pub use sqlite_store::SqliteStore;
pub use store::FileStore;
pub use store::InMemoryStore;
pub use store::SearchMode;
pub use store::SearchQuery;
pub use store::Store;
pub use store::StoreItem;

Modules§

checkpointer
Short-term thread state persistence (Checkpointer)
conversation
对话持久化 Store
embedder
文本嵌入接口
embedding_store
向量增强 Store(EmbeddingStore)
snapshot
Agent 状态快照与回滚
sqlite_conversation
SQLite conversation persistence implementation
sqlite_store
SQLite persistent Store (FTS5 full-text search + optional vector search)
store
Long-term memory Store