Class: HTM::MCP::GetWorkingMemoryTool
- Inherits:
-
FastMcp::Tool
- Object
- FastMcp::Tool
- HTM::MCP::GetWorkingMemoryTool
- Defined in:
- lib/htm/mcp/tools.rb
Overview
Tool: Get working memory contents for session restore
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/htm/mcp/tools.rb', line 90 def call htm = Session.htm_instance robot = HTM::Models::Robot[htm.robot_id] Session.logger&.info "GetWorkingMemoryTool called for robot=#{htm.robot_name}" nodes = robot.robot_nodes_dataset .in_working_memory .eager(node: :tags) .order(Sequel.desc(:last_remembered_at)) .all .filter_map { |rn| format_working_memory_entry(rn) } Session.logger&.info "GetWorkingMemoryTool complete: #{nodes.length} nodes in working memory" { success: true, robot_id: htm.robot_id, robot_name: htm.robot_name, count: nodes.length, working_memory: nodes }.to_json rescue StandardError => e Session.logger&.error "GetWorkingMemoryTool error: #{e.}" { success: false, error: e., count: 0, working_memory: [] }.to_json end |