Commit c76358b

mo khan <mo@mokhan.ca>
2025-08-15 00:03:15
feat: initialize the conversation with the list of resources from the tools
1 parent fab56fa
Changed files (2)
lib/elelem/configuration.rb
@@ -37,7 +37,14 @@ module Elelem
     end
 
     def conversation
-      @conversation ||= Conversation.new
+      @conversation ||= Conversation.new.tap do |conversation|
+        resources = mcp_clients.map do |client|
+          client.resources.map do |resource|
+            resource["uri"]
+          end
+        end.flatten
+        conversation.add(role: :tool, content: resources)
+      end
     end
 
     def tools
lib/elelem/mcp_client.rb
@@ -71,7 +71,11 @@ module Elelem
         Timeout.timeout(2) { @worker.value }
       rescue Timeout::Error
         # Force kill if it doesn't respond
-        Process.kill("KILL", @worker.pid) rescue nil
+        begin
+          Process.kill("KILL", @worker.pid)
+        rescue StandardError
+          nil
+        end
       rescue Errno::ESRCH
         # Process already dead
       end