ワンクリックで
memory
BaseMemory trait, memory types (SimpleMemory, WindowBufferMemory, DummyMemory), and Arc<Mutex> construction patterns.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
BaseMemory trait, memory types (SimpleMemory, WindowBufferMemory, DummyMemory), and Arc<Mutex> construction patterns.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | memory |
| description | BaseMemory trait, memory types (SimpleMemory, WindowBufferMemory, DummyMemory), and Arc<Mutex> construction patterns. |
pub trait BaseMemory: Send + Sync {
fn messages(&self) -> Vec<Message>;
fn add_message(&mut self, message: Message);
fn add_user_message(&mut self, message: impl Into<String>); // convenience
fn add_ai_message(&mut self, message: impl Into<String>); // convenience
fn clear(&mut self);
}
## Memory Types
use langchainx::memory::{SimpleMemory, WindowBufferMemory, DummyMemory};
// Unbounded history
let mem = SimpleMemory::new();
// Sliding window — keeps last N exchanges
let mem = WindowBufferMemory::new(5);
// No-op — for chains that require memory param but don't need it
let mem = DummyMemory::new();
## Construction: Into>>
All memory types implement Into<Arc<Mutex<dyn BaseMemory>>>. Use .into():
use std::sync::Arc;
use tokio::sync::Mutex;
use langchainx::{
memory::SimpleMemory,
schemas::memory::BaseMemory,
};
// Preferred — .into() calls Arc::new(Mutex::new(self))
let mem: Arc<Mutex<dyn BaseMemory>> = SimpleMemory::new().into();
// Equivalent explicit form
let mem = Arc::new(Mutex::new(SimpleMemory::new())) as Arc<Mutex<dyn BaseMemory>>;
Pass to chain/agent builders:
ConversationalChainBuilder::new()
.memory(SimpleMemory::new().into())
...
## Reading from Memory
let mem: Arc<Mutex<dyn BaseMemory>> = SimpleMemory::new().into();
// Lock to read
let guard = mem.lock().await;
let messages = guard.messages();
drop(guard); // release lock before any await
// Lock to write
let mut guard = mem.lock().await;
guard.add_user_message("Hello");
guard.add_ai_message("Hi there!");
Never hold the lock across an .await — use a separate scope or drop before await points.
AgentExecutor, ChatAgent (ReAct), OpenAIToolsAgent, and the Agent trait.
JOB-251 — Why Arc<dyn LLM> over LLMClone, migration pattern, and correct LLM ownership model.
All Chain types — LLMChain, ConversationalChain, SequentialChain, StuffDocuments, ConversationalRetrievalQA, SqlDatabaseChain.
Trait conformance tests, property-based tests (proptest), fuzz targets, and boundary contracts for langchainx traits.
Core langchainx patterns — LLMChain, builder pattern, Chain trait, prompt macros, and basic invocation.
Constructing LLM backends (OpenAI, Claude, DeepSeek, Qwen, Ollama) and configuring CallOptions.