From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=systemreboot.net; s=default; t=1794718076; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I3IJ4HDwDm1If/pLFsx+8H/1k/ZBndjQM5K0+xJCSt4=; b=Tt1efVKIRpYuFNyC/rOJxmbcXutCnT0Q/ByTuHzmEimBQZl3h+EwqiF8LI7Ho/qtT2nwBl oEwldfyF4pww+EraIl3wzVcA1gw2LuOTJOSe1IlMeq+k+qTKZ6G97uY0C6TtpshNehoI3f XRd6g+m9JdtjjpVnj0cfZjCN0iFehVJD5RoDCNyo4b7Og9riRiN4KDlaVbCm/RcFYWhQEU chvDt3D3/yypOf1DODQ3unFc5hkku0PAzGHnU+5WC57uvCNoTwliq43jn2zwp1aum1OE82 3YTyUfPfFfe0Peu6VhU/Rob9TdMw98FMHor+e/0MZq/5q/49hDnDkPbyxZGZiw== Received: from steel ( [192.168.1.1]) by hrrol.systemreboot.net (OpenSMTPD) with ESMTPSA id 07a69c19 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sun, 15 Nov 2026 04:47:56 +0000 (UTC) From: Arun Isaac To: Arun Isaac , Ricardo Wurmus Cc: kaagum@systemreboot.net Subject: [PATCH v2 4/5] Document context compacters. Date: Sun, 15 Nov 2026 04:47:49 +0000 Message-ID: <20261115044752.5595-5-arunisaac@systemreboot.net> X-Mailer: git-send-email 2.54.0 In-Reply-To: <87ik20nycd.fsf@systemreboot.net> References: <87ik20nycd.fsf@systemreboot.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index 67a3ad2..210089a 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,37 @@ If your custom tools require other Guile packages or modules, you may provide ac "GUILE_LOAD_COMPILED_PATH" "/some/path/")) ``` +# Context compaction + +In long conversations, it is helpful to compact messages so that the context window of the model is not exceeded. kaagum supports various compaction strategies. + +## Sliding window compacter + +```scheme +(sliding-window-compacter #:key (context-threshold 0.7) (keep-context 0.2)) +``` +Once `context-threshold` fraction of the context window has been used, the sliding window compacter keeps only the most recent messages corresponding to `keep-context` fraction of the context window. + +To use this compacter, pass `--compacter-eval=(sliding-window-compacter)` to kaagum. You may also configure the compacter parameters using something like `--compacter-eval=(sliding-window-compacter #:context-threshold 0.8 #:keep-context 0.3)`. + +## Summarizing compacter + +```scheme +(summarizing-compacter #:key (context-threshold 0.7) + (keep-context 0.2) + (summarizer-prompt "Summarize all the conversation prior to this point into a single message.")) +``` +Once `context-threshold` fraction of the context window has been used, the summarizing compacter keeps the most recent messages corresponding to `keep-context` fraction of the context window and summarizes all the earlier messages into a single message. + +To use this compacter, pass `--compacter-eval=(summarizing-compacter)` to kaagum. You may also configure the compacter parameters using something like `--compacter-eval=(summarizing-compacter #:context-threshold 0.8 #:keep-context 0.3)`. + +## noop compacter + +```scheme +noop-compacter +``` +The noop compacter is an identity compacter. It doesn't compact at all; use this compacter to disable context compaction. To use this compacter, pass `--compacter-eval=noop-compacter` to kaagum. + # Contributing Please report issues or send patches to the public inbox at [kaagum@systemreboot.net](https://lists.systemreboot.net/kaagum/). -- 2.54.0