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=1794354162; 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=T0qpXdMd4M8MJzBXpwYMmJCVV5XjLXnRtj/TxiDcqRA=; b=oWYB7IiDmHI4Wmz8Yx5BrFljiitnOC6pCW7KKf3FUE6b/VSFkvIvvivq4sH064zgcB3Xuj N14N1k5xWLgol3HLSZxOuhOj8jBxYYey1kmh4fKyeS5bipVBbnUMlsxcIG7Yavm0qkIlVy 4jo91ho52AUPwWP/MyDgsYuoipIxGC/haCNIQ8QegiYsVhphW1II8hckJ24RIIl8a4f1X/ /ys8Pl/gWhbgtTLLK+l37+2uEfc6rnPAskylnkDDPqu1efKssmn75gSHAUndNQYL87ZjaK 3tabCkS84vtb7TLWOZ5BwTh5EsbJzvpofuNsiSIKBtRQsV0EsF+L/27l0irPiQ== Received: from localhost ( [192.168.1.1]) by hrrol.systemreboot.net (OpenSMTPD) with ESMTPSA id dc75eb84 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 10 Nov 2026 23:42:41 +0000 (UTC) From: Arun Isaac To: Ricardo Wurmus Cc: Ricardo Wurmus , kaagum@systemreboot.net Subject: Re: strategies for context management In-Reply-To: <87o6bynnkv.fsf@elephly.net> References: <87ld76e5w0.fsf@elephly.net> <87fqxerqg6.fsf@systemreboot.net> <87jympps3s.fsf@elephly.net> <87eccxoy4k.fsf@elephly.net> <87zevkqf4d.fsf@systemreboot.net> <87o6bynnkv.fsf@elephly.net> Date: Tue, 10 Nov 2026 23:42:40 +0000 Message-ID: <87wlqkp827.fsf@systemreboot.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: Hi Ricardo, > This means that the compaction function will see an ever-increasing > number of messages. I understand that having more context can be > useful to avoid drift and loss of important information, but it also > means that compaction cannot build up its own state. It would have to > perform the same work over and over again, just with more messages > tacked on, yet it has no way to checkpoint its progress. Perhaps a > compacter would need to bring its own infrastructure to avoid > repeating work across turns. It could memoize. That's fairly easy to implement. But I hear you. Let's keep both the original messages and the compacted messages in the state. We'll only send the compacted messages to the LLM and to the compacter, like you suggest. But we still need to keep the original messages for mundane things like saving and resuming sessions. kaagum doesn't support saving/resuming sessions yet, but might in the future. >> - The compacter function is not told how many tokens the previous LLM >> query took. This may be important information. > > Is that information available to kaagum? Yes, certainly. And kaagum passes on that information to the ACP client (agent-shell) too. In agent-shell, you can see the token usage using `M-x agent-shell-show-usage', among other places. Let's make the token usage information available to the compacter. Perhaps it can be a keyword argument #:tokens that is passed to the compacter function. > I don't know enough to understand why it would be desirable to let=20 > the compacter make its own calls instead of considering it an=20 > optional detour in the back and forth between kaagum and the LLM. Integrating the compacter into the TEA loop is very nice from the point of view of remaining strictly functional and free of side-effects. However, I'm leaning towards making it separate for the following reasons: Integrating the compacter into the TEA loop would mean we are exposing the TEA architecture=E2=80=94an implementation detail=E2=80=94to the compac= ter. If we ever decide to move away from the TEA architecture, we won't be able to. Also, the TEA architecture will make the compacter harder to write, and will probably frustrate end-users trying to write a compacter. We'll have to create several more record types=E2=80=94, , etc. to distinguish these from and . If we re-used the same record types, the TEA loop would not know whether they were meant for the compacter or as a regular LLM completion. The compacter may also want to use a different model or even a different LLM provider for summarizing=E2=80=94more reason to not conflate with . Let's start with a non-TEA compacter since it's simpler. If we ever need to, we can move to a TEA-integrated compacter later. I'll send a new WIP patch in the next couple of days. The compacter specifics apart, could you share some more details of your project and what you're trying to achieve? It might help me think along. Regards, Arun