Commit 5de8738

mo khan <mo@mokhan.ca>
2025-11-27 00:08:23
feat: print tool call output and improve exec description
1 parent 585408f
lib/elelem/agent.rb
@@ -65,6 +65,13 @@ module Elelem
       HELP
     end
 
+    def format_tool_call_result(result)
+      return result["stdout"] if result["stdout"]
+      return result["stderr"] if result["stderr"]
+
+      JSON.pretty_generate(result)
+    end
+
     def execute_turn(messages, tools:)
       turn_context = []
 
@@ -96,6 +103,7 @@ module Elelem
 
             puts "Tool> #{name}(#{args})"
             result = toolbox.run_tool(name, args)
+            puts format_tool_call_result(result)
             turn_context << { role: "tool", content: JSON.dump(result) }
           end
 
lib/elelem/system_prompt.erb
@@ -1,4 +1,4 @@
-You are a reasoning coding and system agent.
+You are a reasoning coding and system agent working from: <%= Dir.pwd %>.
 
 - Less is more
 - No code comments
lib/elelem/toolbox.rb
@@ -8,7 +8,7 @@ module Elelem
       full_path.exist? ? { content: full_path.read } : { error: "File not found: #{path}" }
     end
 
-    EXEC_TOOL = Tool.build("execute", "Execute shell commands directly. Commands run in a shell context. Examples: 'date', 'git status'.", { cmd: { type: "string" }, args: { type: "array", items: { type: "string" } }, env: { type: "object", additionalProperties: { type: "string" } }, cwd: { type: "string", description: "Working directory (defaults to current)" }, stdin: { type: "string" } }, ["cmd"]) do |args|
+    EXEC_TOOL = Tool.build("execute", "Run shell commands. For git: execute({\"cmd\": \"git\", \"args\": [\"log\", \"--oneline\"]}). Returns stdout/stderr/exit_status.", { cmd: { type: "string" }, args: { type: "array", items: { type: "string" } }, env: { type: "object", additionalProperties: { type: "string" } }, cwd: { type: "string", description: "Working directory (defaults to current)" }, stdin: { type: "string" } }, ["cmd"]) do |args|
       Elelem.shell.execute(
         args["cmd"],
         args: args["args"] || [],