Class: OllamaAgent::ToolRuntime::Memory
- Inherits:
-
Object
- Object
- OllamaAgent::ToolRuntime::Memory
- Defined in:
- lib/ollama_agent/tool_runtime/memory.rb
Overview
Short-term transcript of planner output, resolved actions, and tool results.
Instance Attribute Summary collapse
-
#tool_descriptions ⇒ String?
Optional text injected into planner prompts (e.g. registry descriptions).
Instance Method Summary collapse
- #append(thought:, action:, result:) ⇒ Object
-
#initialize(limit: 10) ⇒ Memory
constructor
A new instance of Memory.
- #recent(last_n = nil) ⇒ Object
- #tool_descriptions_for_prompt ⇒ Object
Constructor Details
#initialize(limit: 10) ⇒ Memory
Returns a new instance of Memory.
10 11 12 13 14 |
# File 'lib/ollama_agent/tool_runtime/memory.rb', line 10 def initialize(limit: 10) @steps = [] @limit = [Integer(limit), 1].max @tool_descriptions = nil end |
Instance Attribute Details
#tool_descriptions ⇒ String?
Returns optional text injected into planner prompts (e.g. registry descriptions).
8 9 10 |
# File 'lib/ollama_agent/tool_runtime/memory.rb', line 8 def tool_descriptions @tool_descriptions end |
Instance Method Details
#append(thought:, action:, result:) ⇒ Object
16 17 18 19 |
# File 'lib/ollama_agent/tool_runtime/memory.rb', line 16 def append(thought:, action:, result:) @steps << { thought: thought, action: action, result: result } @steps.shift while @steps.size > @limit end |
#recent(last_n = nil) ⇒ Object
21 22 23 24 25 |
# File 'lib/ollama_agent/tool_runtime/memory.rb', line 21 def recent(last_n = nil) return @steps.dup if last_n.nil? @steps.last(Integer(last_n)) end |
#tool_descriptions_for_prompt ⇒ Object
27 28 29 |
# File 'lib/ollama_agent/tool_runtime/memory.rb', line 27 def tool_descriptions_for_prompt @tool_descriptions.to_s end |