Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Capped Conversation History

Maintains a sliding window of conversation messages and persists them to the session as JSONL. Default provider of memory.history.

Details

IDnexus.memory.capped
DependenciesNone

Configuration

KeyTypeDefaultDescription
max_messagesint100Maximum messages to keep in the buffer
persistbooltrueWrite messages to context/conversation.jsonl in the session

Events

Subscribes To

EventPriorityPurpose
io.input10Records user messages
io.output10Records agent responses
tool.invoke50Records tool calls
tool.result50Records tool results
memory.store50Explicit memory storage requests
memory.query50Responds to history queries
memory.compacted50Replaces history with compacted version

Emits

EventWhen
memory.resultResponse to a memory.query

Behavior

  • Messages are stored in a rolling buffer of size max_messages
  • Oldest messages are dropped when the buffer is full
  • If persist: true, each message is appended to context/conversation.jsonl as it arrives
  • On memory.compacted, the buffer is replaced with the compacted messages

Querying History

Other plugins can query conversation history:

bus.Emit("memory.query", events.MemoryQuery{
    Query:     "",    // Not filtered — returns all
    Limit:     50,    // Max messages to return
    SessionID: "...", // Current session
})
// Listen for memory.result event with the messages

Example Configuration

nexus.memory.capped:
  max_messages: 200
  persist: true