public inbox for kaagum@systemreboot.net
 help / color / mirror / Atom feed
From: Arun Isaac <arunisaac@systemreboot.net>
To: Arun Isaac <arunisaac@systemreboot.net>,
	Ricardo Wurmus <rekado@elephly.net>,
	kaagum@systemreboot.net
Subject: [PATCH 2/2] Allow custom tools.
Date: Thu,  5 Nov 2026 00:19:56 +0000	[thread overview]
Message-ID: <20261105002005.22420-2-arunisaac@systemreboot.net> (raw)
In-Reply-To: <87se1grv11.fsf@systemreboot.net>

---
 README.md  | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 bin/kaagum |  7 +++++++
 2 files changed, 55 insertions(+)

diff --git a/README.md b/README.md
index 045598c..67a3ad2 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,54 @@ Install the `kaagum` and `emacs-agent-shell-kaagum` packages from Guix. Then, pu
 ```
 Change to the directory you want to work in. kaagum will only have access to that directory and its contents. Run `M-x agent-shell` and select `kaagum` from the menu.
 
+# Using custom tools with kaagum
+
+kaagum empowers you to equip your agents with custom tools specific to your needs. To do this, you write a scheme file (let's call it `custom-tools.scm`) that defines your custom tools. Then, you pass that file on to kaagum using the `--more-tools=custom-tools.scm` parameter.
+
+What should your custom tools file look like? Here's an example:
+```scheme
+(use-modules (kaagum tools))
+
+(define %string-length
+  (tool #:description "Compute the length of a string."
+        #:parameters `(("str" . ,(tool-parameter
+                                  #:type "string"
+                                  #:description "String whose length to compute"
+                                  #:required? #t)))
+        #:proc (lambda* (#:key str)
+                 (format #t "~a~%" (string-length str)))
+        #:title (lambda* (#:key str)
+                  (format #f "string-length ~s" str))
+        #:kind "other"))
+
+`(("string-length" . ,%string-length))
+```
+The file must return an association list mapping tool names to definitions (`<tool>` objects) as its final expression.
+
+`<tool>` objects are defined using `tool` from `(kaagum tools)`. `tool` takes the following keyword arguments:
+- **description:** string that describes the tool; this is read by the LLM to decide whether and how to use the tool—make it a detailed documentation of the tool and the parameters that it takes.
+- **parameters:** association list mapping tool parameter names to `<tool-parameter>` objects.
+- **proc:** the actual function run if the tool is executed; parameters are passed to it as keyword arguments, and output must be written to standard output
+- **title:** human-readable string describing what the tool is doing; this is used by the ACP client in its UI
+- **kind:** category of tool—one of `"read"`, `"edit"`, `"delete"`, `"move"`, `"search"`, `"execute"`, `"think"`, `"fetch"`, `"switch_mode"`, or `"other"`; this is also used by the ACP client in its UI
+- **container-mappings:** list of Guix `<file-system-mapping>` objects representing file system paths to mount into the container of the tool call process
+- **container-namespaces:** list of namespaces to create for the container—should be like `%namespaces` from Guix's `(gnu build linux-container)`
+
+`<tool-parameter>` objects are defined using `tool-parameter` from `(kaagum tools)`. tool-parameter takes the following keyword arguments:
+- **type:** parameter type—`"string"`, `"boolean"`, etc.
+- **description:** string describing the tool parameter
+- **required?:** `#t` if this parameter is required (that is, mandatory), else `#f`; if the parameter is not required, the default argument must be specified in the `lambda*` function in `#:proc` and `#:title`.
+
+See definitions of built-in tools under `kaagum/tools/*.scm` for examples.
+
+If your custom tools require other Guile packages or modules, you may provide access by setting the `GUILE_LOAD_PATH` and `GUILE_LOAD_COMPILED_PATH` environment variables. If you're using Emacs agent shell, you can do this by setting the `agent-shell-kaagum-environment` variable.
+```elisp
+(setq agent-shell-kaagum-environment
+      (agent-shell-make-environment-variables
+       "GUILE_LOAD_PATH" "/some/path/"
+       "GUILE_LOAD_COMPILED_PATH" "/some/path/"))
+```
+
 # Contributing
 
 Please report issues or send patches to the public inbox at [kaagum@systemreboot.net](https://lists.systemreboot.net/kaagum/).
diff --git a/bin/kaagum b/bin/kaagum
index 75e837f..2c8c9ee 100755
--- a/bin/kaagum
+++ b/bin/kaagum
@@ -50,6 +50,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 #\t "more-tools") #t #f
+                (lambda (opt name arg result)
+                  (acons 'more-tools arg result)))
         (option (list "kagi-api-key-command") #t #f
                 (lambda (opt name arg result)
                   (acons 'kagi-api-key-command arg result)))
@@ -75,6 +78,7 @@ Run kaagum AI agent.
   -k, --api-key-command=COMMAND  command to run to get API key
   -m, --model=MODEL              LLM model name to start new sessions with
                                  (default: \"anthropic/claude-opus-4.8\")
+  -t, --more-tools=FILE          scheme file providing more tools to the agent
 
   --kagi-api-key-command=COMMAND command to run to get Kagi API key
 
@@ -128,6 +132,9 @@ Run kaagum AI agent.
                                   %forge-tools
                                   (if kagi-api-key-command
                                       %kagi-tools
+                                      '())
+                                  (if (assq-ref args 'more-tools)
+                                      (load (assq-ref args 'more-tools))
                                       '())))))
          (parameterize ((%kagi-api-key (and kagi-api-key-command
                                             (get-api-key kagi-api-key-command))))
-- 
2.54.0


  parent reply	other threads:[~2026-11-05  0:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04 17:39 draft: Feature to load external tools Ricardo Wurmus
2026-11-05  0:17 ` Arun Isaac
2026-11-05  0:19   ` [PATCH 1/2] Allow setting environment variables with agent shell Arun Isaac
2026-11-05  0:19   ` Arun Isaac [this message]
2026-11-05  7:08   ` draft: Feature to load external tools Ricardo Wurmus
2026-11-05 10:59     ` Arun Isaac

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261105002005.22420-2-arunisaac@systemreboot.net \
    --to=arunisaac@systemreboot.net \
    --cc=kaagum@systemreboot.net \
    --cc=rekado@elephly.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox