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=1794101747; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ucc/Jf2Yz4esI4vGIucdxLgiU3zluz0jc45y15T4t28=; b=X1LjGijIErBtwPgdGj8cdM06unyLnr8y0g6gverAadUmRTfN+XU8qc+42I6Jk2ubPQatbS +bujMt9pSCgaeayzUqKvcPdMiuok80XKaaDvPH4VnjGD530xbSgF2ejWhtE9Zr/tRPvtTC DJCQRb12e6vldZ3katFPugftT37UWWLXPZ4CxvulwAWnVH7WqhK0xUxuX14EZLG5bdkQRT KuKrPr89oUynlkyofWBMvppTcFFHm9/8+ekiNhXiy+Me+FpCQThMED/2OSlZQ/Qho231Dm nvsECHqLXlS6nHRu7z88EDa558sXvHs7/+RsgSZYHkJLA91zxRZUEd/byMI78w== Received: from localhost ( [192.168.1.1]) by hrrol.systemreboot.net (OpenSMTPD) with ESMTPSA id c5a3b5e8 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sun, 8 Nov 2026 01:35:47 +0000 (UTC) From: Arun Isaac To: Ricardo Wurmus Cc: Ricardo Wurmus , kaagum@systemreboot.net Subject: Re: strategies for context management In-Reply-To: <87eccxoy4k.fsf@elephly.net> References: <87ld76e5w0.fsf@elephly.net> <87fqxerqg6.fsf@systemreboot.net> <87jympps3s.fsf@elephly.net> <87eccxoy4k.fsf@elephly.net> Date: Sun, 08 Nov 2026 01:35:46 +0000 Message-ID: <87zevkqf4d.fsf@systemreboot.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: Hi Ricardo, > My proposal is to add a compaction strategy record with a predicate > and a handler. The predicate takes the current state and decides > whether compaction should be performed. The handler takes state and > returns new state. That's a neat interface=E2=80=94it avoids hard-coding a specific compacter;= I like it. I have written up a draft (and completely untested) patch implementing it. Let me know what you think, and if you'd be happy to flesh it out and experiment with it a bit. The patch follows in a subsequent mail. Some differences from your proposal: - Instead of a predicate and a handler, I have a single function. The function can be identity for a no-compaction strategy. - The compacter doesn't update the state. The state remains complete and whole, just like without compaction. The compaction only happens in do-effect, just before querying the LLM. Other things to think about: - The compacter function is directly exposed to the JSON tree of the messages; we should probably introduce an record type abstraction. - The compacter function is not told how many tokens the previous LLM query took. This may be important information. - The compacter is a naked function; maybe a wrapping compacter record type would be wise, but I can't think of a pressing immediate reason to wrap it. - The --compacter argument only allows specifying compacters from user-specified files. Ideally, we'd want kaagum to provide a library of compacters, and the user to have some way of choosing from them as well. > A complication is that a handler may issue LLM calls (e.g. to > summarize stuff), and I don't know how this would slot into the TEA > loop. Perhaps triggering session/fork would be appropriate then. That is a valid use case, and we should support it. But it may be best to let the compacter make its own LLM calls without having to integrate those LLM calls into the TEA loop. Regards, Arun