about summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorArun Isaac2026-07-22 00:27:06 +0100
committerArun Isaac2026-07-22 00:35:30 +0100
commit7918c9d422962d8dec4fb9fa410a51daa6d6ebe7 (patch)
tree9d30849d9e7021e792efe0de727a9448a6a7697b /bin
parentf6435ee1c013f7b964b5e8a61fe403043b4da165 (diff)
downloadkaagum-7918c9d422962d8dec4fb9fa410a51daa6d6ebe7.tar.gz
kaagum-7918c9d422962d8dec4fb9fa410a51daa6d6ebe7.tar.lz
kaagum-7918c9d422962d8dec4fb9fa410a51daa6d6ebe7.zip
Add tracing.
This will aid debugging and let users report issues more precisely and
reproducibly.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/kaagum24
1 files changed, 19 insertions, 5 deletions
diff --git a/bin/kaagum b/bin/kaagum
index 138e62c..9d5353d 100755
--- a/bin/kaagum
+++ b/bin/kaagum
@@ -21,6 +21,7 @@ exec guile --no-auto-compile -e main -s "$0" "$@"
 ;;; along with kaagum.  If not, see <https://www.gnu.org/licenses/>.
 
 (use-modules (rnrs io ports)
+             (srfi srfi-26)
              (srfi srfi-37)
              (ice-9 match)
              (kaagum config)
@@ -28,6 +29,7 @@ exec guile --no-auto-compile -e main -s "$0" "$@"
              (kaagum tea)
              (kaagum tools base)
              (kaagum tools forges)
+             (kaagum trace)
              (kaagum utils))
 
 (define (invalid-option opt name arg result)
@@ -47,6 +49,9 @@ exec guile --no-auto-compile -e main -s "$0" "$@"
         (option (list #\k "api-key-command") #t #f
                 (lambda (opt name arg result)
                   (acons 'api-key-command arg result)))
+        (option (list "trace-file") #t #f
+                (lambda (opt name arg result)
+                  (acons 'trace-file arg result)))
         (option (list #\v "version") #f #f
                 (lambda (opt name arg result)
                   (acons 'version #t result)))
@@ -67,6 +72,8 @@ Run kaagum AI agent.
   --model=MODEL                  LLM model name to start new sessions with
                                  (default: \"anthropic/claude-opus-4.6\")
 
+  --trace-file=FILE              trace out all interactions in FILE
+
   --version                      print version and exit
   --help                         print this help and exit
 "
@@ -105,8 +112,15 @@ Run kaagum AI agent.
          (exit #t))
        (unless (assq-ref args 'api-key-command)
          (die "--api-key-command not specified"))
-       (run-tea-loop (assq-ref args 'api-base-uri)
-                     (get-api-key (assq-ref args 'api-key-command))
-                     (assq-ref args 'model)
-                     (append %base-tools
-                             %forge-tools))))))
+       (let ((thunk (cut run-tea-loop
+                         (assq-ref args 'api-base-uri)
+                         (get-api-key (assq-ref args 'api-key-command))
+                         (assq-ref args 'model)
+                         (append %base-tools
+                                 %forge-tools))))
+         (if (assq-ref args 'trace-file)
+             (call-with-output-file (assq-ref args 'trace-file)
+               (lambda (trace-port)
+                 (parameterize ((%trace-port trace-port))
+                   (thunk))))
+             (thunk)))))))