Class: Insika::Tools::Remember

Inherits:
RubyLLM::Tool
  • Object
show all
Defined in:
lib/insika/tools/remember.rb

Overview

Write path of the cross-session memory: the agent stores a fact (key+value, durable upsert) or a note (value without key) on demand. Deterministic — NO model call. System builtin (like load_skill/tool_search): require "ruby_llm" stays in THIS file, loaded lazily by the Executor in create_chat.

Instance Method Summary collapse

Constructor Details

#initialize(store, tenant, event_stream:, state:) ⇒ Remember

Returns a new instance of Remember.



22
23
24
25
26
27
28
# File 'lib/insika/tools/remember.rb', line 22

def initialize(store, tenant, event_stream:, state:)
  @store = store
  @tenant = tenant
  @event_stream = event_stream
  @state = state
  super()
end

Instance Method Details

#execute(value:, key: nil) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/insika/tools/remember.rb', line 30

def execute(value:, key: nil)
  if key.to_s.strip.empty?
    note = @store.add_note(tenant: @tenant, text: value.to_s)
    emit("note", note.id)
    { remembered: "note", id: note.id }
  else
    @store.put_fact(tenant: @tenant, key: key.to_s, value: value.to_s)
    emit("fact", key.to_s)
    { remembered: "fact", key: key.to_s }
  end
end

#nameObject

otherwise RubyLLM derives "insika--tools--remember" from the class name.



20
# File 'lib/insika/tools/remember.rb', line 20

def name = "remember"