public inbox for kaagum@systemreboot.net
 help / color / mirror / Atom feed
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: Sun, 08 Nov 2026 01:35:46 +0000	[thread overview]
Message-ID: <87zevkqf4d.fsf@systemreboot.net> (raw)
In-Reply-To: <87eccxoy4k.fsf@elephly.net>


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—it 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 <llm-request-message> 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

  reply	other threads:[~2026-11-08  1:35 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 [this message]
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
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=87zevkqf4d.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