From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sender6-of-o51.zoho.com (sender6-of-o51.zoho.com [165.173.180.51]) by hrrol.systemreboot.net (OpenSMTPD) with ESMTPS id 2333ec32 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Wed, 4 Nov 2026 17:39:39 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1793813975; cv=none; d=zohomail.com; s=zohoarc; b=BCzuY3bwFk7Ln3euJroZWmt7VfaVzTZT25lSmyy07AzcXk7KH+QIwezeoSX4xQMgaZ8cK0DxgY0TrYkMawB+JMPvwVY4vjvusOibtvOucL2wqns1KOxNyTOGUJNz7K10OkTU+DirVcabrHXnHRvhZO0Z4ic/rj11LrRTTbCr+AQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793813975; h=Content-Type:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=l47WkSeDoSniiX25FnOXg+JrIFcKBex6HiFAlOF2BXY=; b=GhQe2n627iKG+Sk9/KUUZqtR645YEAuBUC9QQ4fM1245Jiiy5hE5ZNyaSWo08V2bqrMXDuhLmXne3RKauTkexMz7lfB5lvWp58z2y9P9/ARHCrveaaKbuCn7AyzMJkU1FhiGGB6lnAd/G8p4Q4LA67ZAKaousbrFjGps3YSPL+g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= DKIM-Signature: a=rsa-sha256; b=iKEkJKyvnaHkp9pn/WPmx0afKKTJiHyuD6ox0Tb3Q+Fh62+SRgnHp2ZZIJ42iW5y+l1g8bc3Oo3qouZ5yQA8b0i+2jojy0wmMW2qN34csgAkUVPx/xP26Vj1zwg1it1ogOTETfviwRy+9npr6ByKH1wzpuQ/c9dZMj4i0B4NX9M=; c=relaxed/relaxed; s=zoho; d=elephly.net; v=1; bh=l47WkSeDoSniiX25FnOXg+JrIFcKBex6HiFAlOF2BXY=; h=Content-Description:Content-ID:Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Resent-Sender:Resent-Cc:Resent-Date:Resent-To:Reply-To:Resent-Message-ID:Resent-From:Sender:Subject:To:Date:From:Message-Id:Reply-To:Subject:To:Cc; Received: by smtp.zohomail.com with SMTPS id 1793813974769611.0947935847249; Wed, 4 Nov 2026 09:39:34 -0800 (PST) From: Ricardo Wurmus To: kaagum@systemreboot.net Subject: draft: Feature to load external tools User-Agent: mu4e 1.14.4; emacs 31.1 Date: Wed, 04 Nov 2026 18:39:31 +0100 Message-ID: <87jymsfqcs.fsf@elephly.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/293.791.62 X-ZohoMailClient: External List-Id: --=-=-= Content-Type: text/plain; format=flowed 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 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-WIP-external-tools.patch >From 9f99a60b36188e8ce03f53f21d5437063a4a2945 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus 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{} objects." (else (assertion-violation (focus tool-call-status tool-call) "Invalid tool call status"))))) + + + +(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 --=-=-=--