Class: OllamaAgent::Tools::MemoryStore

Inherits:
Base
  • Object
show all
Defined in:
lib/ollama_agent/tools/memory_tools.rb

Overview

Store a fact in long-term memory for future sessions.

Constant Summary

Constants inherited from Base

Base::RISK_LEVELS

Instance Attribute Summary

Attributes inherited from Base

#description, #input_schema, #name, #output_schema, #requires_approval, #risk_level

Instance Method Summary collapse

Methods inherited from Base

#initialize, #to_anthropic_schema, #to_ollama_schema, #to_s, tool_description, tool_name, tool_output_schema, tool_requires_approval, tool_risk, tool_schema

Constructor Details

This class inherits a constructor from OllamaAgent::Tools::Base

Instance Method Details

#call(args, context: {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ollama_agent/tools/memory_tools.rb', line 23

def call(args, context: {})
  memory = context[:memory_manager]
  return "memory_store: no memory manager in context" unless memory

  key       = args["key"].to_s.strip
  value     = args["value"].to_s
  namespace = args["namespace"] || "default"

  memory.remember(key, value, tier: :long_term, namespace: namespace)
  "Stored: #{key} = #{value.inspect[0, 80]}"
end