From: Ricardo Wurmus <rekado@elephly.net>
To: kaagum@systemreboot.net
Subject: draft: Feature to load external tools
Date: Wed, 04 Nov 2026 18:39:31 +0100 [thread overview]
Message-ID: <87jymsfqcs.fsf@elephly.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 1592 bytes --]
Hi Arun,
I'd like to grant kaagum access to a bunch of custom tools that
I'm about to write (e.g. for web fetch, bioinfo data retrieval,
interfacing with a qemu socket, etc), and I thought it would be
helpful to have kaagum load user-specified Guile modules from
KAAGUM_TOOLS_PATH.
The implementation is rough, but it works for my purposes. I
haven't put any polish on it as I'm not sure going through an
environment variable is desirable. Below is a patch. Note that
this probably isn't a good way to do things when a tool requires
other Guile packages, because nothing is added to the Guile load
path.
This also required a change to agent-shell-kaagum-make-client to
set the variable; other agent-shell clients have a dedicated
variable for setting environment variables, which could be a
useful addition anyway:
--8<---------------cut here---------------start------------->8---
(defun agent-shell-kaagum-make-client (buffer)
"Create a kaagum ACP client using BUFFER as context."
(agent-shell--make-acp-client :command
agent-shell-kaagum-command
:command-params
agent-shell-kaagum-parameters
:context-buffer buffer
:environment-variables
(agent-shell-make-environment-variables
"KAAGUM_TOOLS_PATH"
"/home/rekado/dev/external-tools")))
--8<---------------cut here---------------end--------------->8---
What do you think?
--
Ricardo
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-WIP-external-tools.patch --]
[-- Type: text/x-patch, Size: 3595 bytes --]
From 9f99a60b36188e8ce03f53f21d5437063a4a2945 Mon Sep 17 00:00:00 2001
From: Ricardo Wurmus <rekado@elephly.net>
Date: Wed, 4 Nov 2026 13:15:22 +0100
Subject: [PATCH] WIP: external tools
---
bin/kaagum | 4 +++-
kaagum/tools.scm | 38 +++++++++++++++++++++++++++++++++++++-
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/bin/kaagum b/bin/kaagum
index 45a24d9..6696f72 100755
--- a/bin/kaagum
+++ b/bin/kaagum
@@ -27,6 +27,7 @@ exec guile --no-auto-compile -e main -s "$0" "$@"
(kaagum config)
(kaagum openai)
(kaagum tea)
+ (kaagum tools)
(kaagum tools base)
(kaagum tools forges)
(kaagum tools kagi)
@@ -128,7 +129,8 @@ Run kaagum AI agent.
%forge-tools
(if kagi-api-key-command
%kagi-tools
- '())))))
+ '())
+ (external-tools)))))
(parameterize ((%kagi-api-key (pk (and kagi-api-key-command
(get-api-key kagi-api-key-command)))))
;; (trace 'kagi "Key ~a" (%kagi-api-key))
diff --git a/kaagum/tools.scm b/kaagum/tools.scm
index 65060ea..08f10d2 100644
--- a/kaagum/tools.scm
+++ b/kaagum/tools.scm
@@ -23,21 +23,25 @@
#:use-module (rnrs records syntactic)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
+ #:use-module (srfi srfi-31)
#:use-module (srfi srfi-43)
#:use-module (ice-9 match)
#:use-module (gnu build linux-container)
#:use-module (gnu system file-systems)
#:use-module (json)
#:use-module (lens)
+ #:use-module ((guix ui) #:select (load*))
#:use-module (kaagum container)
#:use-module (kaagum records)
#:use-module (kaagum utils)
+ #:autoload (ice-9 ftw) (scandir)
#:export (tool-call-parse-failure?
tool-call-parse-failure-message
tool->spec
spec->tool-call
- eval-tool-call))
+ eval-tool-call
+ external-tools))
(define (readonly-cwd-only-mappings cwd arguments)
(list (file-system-mapping
@@ -303,3 +307,35 @@ available tools to their respective @code{<tool>} objects."
(else
(assertion-violation (focus tool-call-status tool-call)
"Invalid tool call status")))))
+
+
+\f
+(define (tool-directories)
+ "Return the list of directories containing tools."
+ (filter file-exists?
+ (map (cut string-append <> "/kaagum/tools")
+ (parse-path (getenv "KAAGUM_TOOLS_PATH")))))
+
+(define (tool-files directory)
+ "Return the list of source files that define Kaagum tools."
+ (define dot-scm?
+ (cut string-suffix? ".scm" <>))
+ (map (cut string-append directory "/" <>)
+ (scandir directory dot-scm?)))
+
+(define (external-tools)
+ "Load all external tools."
+ (define tag
+ (make-prompt-tag "user-code"))
+ (append-map (lambda (file)
+ (load* file '((kaagum container)
+ (kaagum lens)
+ (kaagum openai)
+ (kaagum records)
+ (kaagum tea)
+ (kaagum tools)
+ (kaagum trace)
+ (kaagum utils)
+ (kaagum web)
+ )))
+ (append-map tool-files (tool-directories))))
--
2.55.0
next reply other threads:[~2026-11-04 17:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 17:39 Ricardo Wurmus [this message]
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 ` [PATCH 2/2] Allow custom tools Arun Isaac
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=87jymsfqcs.fsf@elephly.net \
--to=rekado@elephly.net \
--cc=kaagum@systemreboot.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