rig-memory
Conversation memory policies for the Rig agent framework.
rig-core ships the ConversationMemory trait and an in-process
InMemoryConversationMemory backend. This crate provides reusable named
policies for shaping loaded history before it is sent to the model:
- [
NoopMemoryPolicy] — identity policy, useful as a default. - [
SlidingWindowMemory] — keep the most recentNmessages, dropping any leading orphan tool result. - [
TokenWindowMemory] — keep the most recent messages that fit within a token budget supplied by a [TokenCounter].
Usage
use ;
let memory = new
.with_filter;
For backends other than InMemoryConversationMemory, apply a policy directly:
use ;
let policy = last_messages;
let trimmed = policy.apply?;
To wrap any backend with a policy and propagate policy errors to the caller
(rather than silently degrading to identity on failure), use PolicyMemory:
use ;
let memory = new;