Commit 605974d

mo khan <mo@mokhan.ca>
2026-01-17 01:14:29
feat: only store the final turn context response
1 parent abb2232
Changed files (1)
lib
elelem
lib/elelem/agent.rb
@@ -66,7 +66,8 @@ module Elelem
         break if errors >= 3
       end
 
-      history << { role: "assistant", content: ctx.map { |c| c[:content] }.join("\n") }
+      final_content = ctx.reverse.find { |m| m[:role] == "assistant" }&.[](:content) || ""
+      history << { role: "assistant", content: final_content }
     end
 
     def fetch_response(ctx)