Commit ac76fef

mo khan <mo@mokhan.ca>
2026-01-26 22:44:19
refactor: extract method to fork an agent
1 parent ab77b45
Changed files (2)
lib
lib/elelem/plugins/builtins.rb
@@ -49,8 +49,7 @@ Elelem::Plugins.register(:builtins) do |agent|
       Keep it minimal. No fluff.
     PROMPT
 
-    sub = Agent.new(agent.client, toolbox: agent.toolbox, terminal: agent.terminal, system_prompt: system_prompt)
-    sub.turn("Generate AGENTS.md for this project")
+    agent.fork(system_prompt: system_prompt).turn("Generate AGENTS.md for this project")
   end
 
   agent.commands.register("reload", description: "Reload plugins and source") do
lib/elelem/agent.rb
@@ -33,6 +33,10 @@ module Elelem
       @conversation.to_a(system_prompt: system_prompt)
     end
 
+    def fork(system_prompt:)
+      Agent.new(client, toolbox: toolbox, terminal: terminal, system_prompt: system_prompt)
+    end
+
     def turn(input)
       @conversation.add(role: "user", content: input)
       ctx = []