Aakash Howlader
All writing

CtxSift: compress and recall agent context

Use CtxSift to compress command output, recall coding-agent context after compaction, and check the source when a summary leaves out a detail.

An open card-catalog drawer with a magnifying glass over one card and a yellow ribbon leading back to a roll of paper.

TL;DR: CtxSift compresses command output and saves the result for later recall. Below, I use the publishing code from this site to capture a finding, retrieve it in another command and check the original source for something the compression didn’t answer. The useful part is remembering where to look without treating a summary as the whole truth.

While building this site, the work moved through quite a few different things. First, bring over the old posts. Then the design, Markdown metadata, selected projects, Docker, old links and deployment. Later, I decided the first design wasn’t personal enough and we went back to the pictures again. 😄

Somewhere in that journey, I asked for selected: true in the post metadata. I didn’t want to edit the homepage every time I wanted to feature a different article. It was a small decision, but it touched the schema, the code loading published posts and the homepage using them.

Now imagine coming back to that work after a long session. You remember agreeing on the flag, but which file validates it? Does a selected draft appear on the homepage? Do you need to go through the source again just to get back to that answer?

That is the sort of repeated recollection I wanted to reduce when I built CtxSift. My earlier post about extending coding-agent sessions explains the motivation. Here, I went back to the site’s files and made a small walkthrough you can run yourself. The site-building story is real; this is a new run against a snapshot of its source.

What we are trying to remember

The personal-site story covers the wider journey. For this example, I kept three source files from that site:

src/lib/post-schema.mjs   # Validates article metadata.
src/lib/posts.ts          # Loads published posts.
src/pages/index.astro     # Chooses what appears on the homepage.

The first question is deliberately specific: how do selected posts and drafts reach the homepage?

Reading the files gives us the answer. The schema defines draft and selected as booleans, both defaulting to false. The loader excludes drafts. The homepage takes those published posts and filters them using post.data.selected.

So a post can have selected: true and still stay out of the homepage if it is a draft. The filtering happens before the selection. That order is something I want the agent to keep, rather than remembering only that a selected flag exists.

Install CtxSift and open the example

This walkthrough uses CtxSift 1.0.6, the published version I checked for this post. You need Python 3.12 or later, uv and a working C/C++ build toolchain for the local model dependency. The Python runtime also needs SQLite 3.41 or newer for the vector lookup used here. The installation guide has the platform-specific steps.

uv tool install 'ctxsift==1.0.6' \
  --index https://download.pytorch.org/whl/cpu \
  --index-strategy unsafe-best-match
ctxsift --help

Download the walkthrough files and unpack them into a new directory outside an existing Git checkout. The archive contains the three source files, a CPU configuration, instructions and the captured results. It is a reading exercise; you don’t need to install Astro or build a second website.

From the unpacked directory:

mkdir -p .ctxsift
cp demo-config.toml .ctxsift/config.toml
ctxsift doctor

The install command includes the official PyTorch CPU index alongside PyPI so this example doesn’t pull in a CUDA build. The supplied configuration uses Qwen3.5 0.8B Q4_K_M GGUF for compression and all-MiniLM-L6-v2 for embeddings, both on CPU. The embedding choice keeps this example smaller than the default setup. The first run downloads the model files; allow for that as well as inference time. The project’s CPU setup lists 8 GB RAM as its minimum. There is no hosted model or API key in this example.

I hit the SQLite requirement while testing in a container with an older runtime. Compression completed, but recall raised A LIMIT or 'k = ?' constraint is required on vec0 knn queries. The sqlite-vec documentation explains why its LIMIT form needs SQLite 3.41+. Updating the SQLite library used by Python resolved that part of the setup; installing a newer sqlite3 shell alone wouldn’t change Python’s linked library.

For your own repository, ctxsift configure offers the guided setup and can install the agent skill. The hand-written configuration here makes the example’s choices explicit. CtxSift finds a Git workspace from its root and normally keeps its configuration and database under .git/ctxsift/. Outside Git, it uses .ctxsift/ in the current directory. That is why the unpack location matters: I want this exercise to have its own records.

Capture a finding the agent can use later

My first attempt used the default Granite 350M model. It returned this:

Preserve the file paths and the exact filtering expressions. Keep the answer concise.

Well, that is short. It also tells me almost nothing about the code. Changing the intent to exact-lines kept a chunk of the schema but still missed the loader and homepage expressions. I kept both results in the download. A stricter instruction didn’t turn that run into useful evidence.

I switched the compressor to Qwen3.5 0.8B. At 256 output tokens, that run also stopped within the schema. With a 1,024-token budget, it kept the schema and the published-post loader, but still omitted the homepage code. Those results are in the download as well. Increasing the budget kept more evidence; it didn’t make the answer complete.

Here is that last command. The downloadable configuration uses Qwen, and command capture gives CtxSift the command as well as the instruction:

ctxsift compress --intent recall --max-output-tokens 1024 \
  "Explain how selected posts and drafts reach the homepage. Preserve the file paths and the exact filtering expressions. Keep the answer short." \
  -- cat src/lib/post-schema.mjs src/lib/posts.ts src/pages/index.astro

The recall intent asks for evidence useful in a later lookup. The words after it say which evidence I need. The -- separates that instruction from the command CtxSift runs.

Command capture also gives it the command, working directory and exit status. If I only pipe an old text file into it, the text can still be compressed, but that isn’t the same as capturing the original command and its execution metadata. The CLI reference describes both forms and the other intents.

Relevant lines from the returned text are below. This is an excerpt; the full result is in the download.

draft: z.boolean().default(false),
selected: z.boolean().default(false),
export async function publishedPosts() {
const posts = await getCollection('blog', ({ data }) => !data.draft);

The returned text contains the draft filter and metadata defaults. I can use it to find that code again. It does not include the homepage’s selection expression, so it hasn’t answered the whole original question. The three source files are still there, and I need the homepage file before changing that part of the site.

Recall it in another command

Later in the same unpacked workspace, run:

ctxsift recall --limit 1 "selected posts drafts homepage"

This is a separate process. It looks up the stored record rather than relying on what the previous shell command printed. That is the part an agent can use after a context compaction or interruption: retrieve the finding before deciding whether to run the original exploration again.

The metadata at the start of my result was:

[4] fresh score=286
Captured at: 2026-11-04T06:18:52Z (1 minute ago)
Instruction: Explain how selected posts and drafts reach the homepage. Preserve the file paths and the exact filtering expressions. Keep the answer short.
Command: cat src/lib/post-schema.mjs src/lib/posts.ts src/pages/index.astro
Exit code: 0
Files: src/lib/posts.ts
Matched: fts, instruction, compressed_output, command, file_paths, vector

Its Summary section contains the saved text from the capture above. The homepage code is still absent. The full recall transcript is in the download.

The result includes the saved summary and information about its capture, including the command and referenced files when available. I can follow those paths instead of starting a fresh search through the whole project. Record IDs, timestamps and scores belong to the local run; yours won’t need to match mine.

This doesn’t put an entire conversation back into the model’s context. The agent needs to load the skill and actually call recall. Installing the executable on a machine doesn’t make every agent remember to use it.

The next question needs something the compression left out

Now change the question. If I select four projects, does the homepage show all four or only the first three?

That also came from building this site. I wanted to choose featured projects with a flag, without having to reorder the list or edit homepage code every time. The homepage has a three-post limit for its latest-writing section, which would be quite easy to confuse with a limit on selected projects if you only half remembered the discussion.

The captured command read the homepage. The returned text left it out. Recall cannot give me that missing project rule from this saved output, so I open the source:

sed -n '1,48p' src/pages/index.astro

Near the top, posts.slice(0, 3) chooses the latest posts. Farther down, the project list uses projects.filter(p => p.selected === true).map(...). There is no three-project slice there. Four selected entries can appear; the limit belongs to a different section.

That difference was present in the original command output and absent from the compressed result. I have to check it before making the next change. A valid fragment of the schema doesn’t tell me what the homepage does with projects, even if both pieces of code came from the same capture.

Also, CtxSift’s database stores the compressed output and capture information, including hashes. It isn’t a raw-output archive you can ask to expand back into everything that went into the model. If I need the original text, I need the source file or a separately retained log. A hash can help identify content; it cannot turn a summary back into that content.

What happens when the source changes?

In the disposable example, I added a newline to the copied loader, recalled the record, then restored the file:

cp src/lib/posts.ts posts-before.ts
printf '\n' >> src/lib/posts.ts
ctxsift recall --limit 1 "selected posts drafts homepage"
mv posts-before.ts src/lib/posts.ts

The same record changed from:

[4] fresh score=286

to:

[4] stale_changed score=156

The summary stayed the same. The label warned that its referenced source had changed.

Notice the Files line in the recall result: this run lists src/lib/posts.ts. It does not list every file passed to cat. I can’t use its fresh label as proof that the .mjs schema and .astro homepage were also checked. The change exercise targets the loader that the record actually references.

Freshness is useful evidence, but it has that specific scope. An unchanged referenced file doesn’t prove that the model interpreted it correctly, or that an external service behaves the same way today. A changed file tells me the old finding needs checking before I use it for a new edit.

For the same reason, I wouldn’t recall a successful build from yesterday and use it as proof that today’s changes pass. Recall can tell me which check to run and what failed before. The current build still has to run.

Where I would use this in an actual session

I don’t want every command to go through another model. If I need to know the current Git branch, git status --short --branch already gives a small, useful answer. Passing it through compression would just add work.

I would use CtxSift when the output is large, the question is narrower than the output and the finding is likely to matter again. A long build log with one publishing failure is a good candidate. So is a source inspection spanning several files, if the agent needs to remember the relationship between them after moving on to something else.

The instruction matters quite a bit. “Summarize this” gives the model room to decide what I care about. “Keep the failing test name, the error and the source path exactly” gives it something I can check. For verbatim lines, the CLI also has an exact-lines intent. I would still compare important commands, flags and conditions with the original before acting on them.

There is another distinction from the Trimwise walkthrough. That example deals with extracting text within a budget and preserving source spans. Here, the useful object is a saved command finding that can be retrieved in a later step. Neither approach makes an omitted condition safe to assume.

Remember enough to continue, then check what matters

The part I wanted to improve was the repeated reading just to return to a fact we had already established. In this site’s case, that could be the relationship between a Markdown flag, the published-post loader and the homepage. CtxSift gives the agent a way to save that finding and look it up again.

But if the next change involves the homepage, I want it to open the homepage code that the compressed result left out. If a referenced source changed, I want it to notice. And if it is about to publish something, I want a fresh build rather than an old green result from a cache.

I like getting more useful work out of a session. Spending fewer tokens only to confidently forget the condition that mattered would be a rather annoying way to do it. 😄

Keep reading

All writing

Software. Football. Heavy metal.

Aakash HowladerSame person. Different playgrounds.