From: Arun Isaac <arunisaac@systemreboot.net>
To: Ricardo Wurmus <rekado@elephly.net>
Cc: Ricardo Wurmus <rekado@elephly.net>, kaagum@systemreboot.net
Subject: Re: strategies for context management
Date: Tue, 10 Nov 2026 23:42:40 +0000 [thread overview]
Message-ID: <87wlqkp827.fsf@systemreboot.net> (raw)
In-Reply-To: <87o6bynnkv.fsf@elephly.net>
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
> the compacter make its own calls instead of considering it an
> 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—an implementation detail—to the compacter. 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—<compacter-llm-request>,
<compacter-llm-response>, etc. to distinguish these from <llm-request>
and <llm-response>. 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—more reason to not
conflate <compacter-llm-request> with <llm-request>.
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
next prev parent reply other threads:[~2026-11-10 23:42 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 8:11 Ricardo Wurmus
2026-11-06 14:21 ` Arun Isaac
2026-11-06 21:28 ` Ricardo Wurmus
2026-11-07 8:15 ` Ricardo Wurmus
2026-11-08 1:35 ` Arun Isaac
2026-11-08 1:36 ` [PATCH] Support context compaction Arun Isaac
2026-11-09 13:25 ` strategies for context management Ricardo Wurmus
2026-11-10 23:42 ` Arun Isaac [this message]
2026-11-13 22:41 ` [PATCH 1/4] Add message record equality comparators Arun Isaac
2026-11-13 22:41 ` [PATCH 2/4] Support context compaction Arun Isaac
2026-11-13 22:41 ` [PATCH 3/4] Add sliding window compacter Arun Isaac
2026-11-13 22:41 ` [PATCH 4/4] Allow loading compacter from file Arun Isaac
2026-11-13 22:46 ` strategies for context management Arun Isaac
2026-11-15 4:47 ` [PATCH v2 0/5] Context compaction Arun Isaac
2026-11-19 14:28 ` Ricardo Wurmus
2026-11-19 14:29 ` Ricardo Wurmus
2026-11-19 18:43 ` Arun Isaac
2026-11-20 5:39 ` Ricardo Wurmus
2026-11-20 5:56 ` Ricardo Wurmus
2026-11-20 13:42 ` Arun Isaac
2026-11-20 13:45 ` Arun Isaac
2026-11-20 14:01 ` Ricardo Wurmus
2026-11-22 16:54 ` Arun Isaac
2026-11-15 4:47 ` [PATCH v2 1/5] Support context compaction Arun Isaac
2026-11-15 4:47 ` [PATCH v2 2/5] Add sliding window compacter Arun Isaac
2026-11-15 4:47 ` [PATCH v2 3/5] Add summarizing compacter Arun Isaac
2026-11-15 4:47 ` [PATCH v2 4/5] Document context compacters Arun Isaac
2026-11-15 4:47 ` [PATCH v2 5/5] Allow user-defined " Arun Isaac
2026-11-08 1:43 ` strategies for context management 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=87wlqkp827.fsf@systemreboot.net \
--to=arunisaac@systemreboot.net \
--cc=kaagum@systemreboot.net \
--cc=rekado@elephly.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