Class: Mistri::Memory

Inherits:
Object
  • Object
show all
Defined in:
lib/mistri/memory.rb

Overview

Durable knowledge that outlives a session, living wherever the host says: an org's row, a user record, a file. What memory means (per org, per user, per project) is the host's call; Mistri only reads and replaces it.

memory = Mistri::Memory.new(
read: -> { org.agent_memory.to_s },
write: ->(text) { org.update!(agent_memory: text) }
)
agent = Mistri.agent("claude-opus-4-8", tools: [*Mistri::Tools.memory(memory)])

Instance Method Summary collapse

Constructor Details

#initialize(read:, write:) ⇒ Memory

Returns a new instance of Memory.



14
15
16
17
# File 'lib/mistri/memory.rb', line 14

def initialize(read:, write:)
  @read = read
  @write = write
end

Instance Method Details

#readObject



19
# File 'lib/mistri/memory.rb', line 19

def read = @read.call.to_s

#replace(content) ⇒ Object



21
22
23
24
# File 'lib/mistri/memory.rb', line 21

def replace(content)
  @write.call(content.to_s)
  nil
end