Show HN: ctx – Search the coding agent history already on your machine (github.com)

65 points by luca-ctx ↗ HN
Coding agents don't have long-term memory.

But you do have months of full-fidelity agent transcripts stored on your machine.

A simple solution that goes a long way: ingest those transcripts and logs into a structured SQLite database, then search them with ranked text match. Everything is fully local and doesn't require anything fancy like a graph database or hosted memory service.

This is the idea behind ctx, a Rust CLI that handles the ingestion and searching.

We give our agents a skill that tells them to reference past sessions before working in an area. Usually we do this through an "Agent History Research Subagent" whose job is just to prepare a short brief covering any relevant history before the task begins.

A real example: sometimes our test suite runs would fail because disk was full on the runner. The correct approach was to run the cleanup runbook, but the root cause of the failure was not clear to the agents, so they would think it was a test regression and go down the wrong rabbit hole debugging. When the agent searched history, it realized this failure had been encountered before and found the right workaround immediately. That got the agent onto the right cleanup path, and later we improved the log output so the same failure would be clearer next time. It's a boring story, but it's real agent productivity.

Another nice use case is quickly generating session transcripts for sharing. You can exclude the noisy intermediate messages, so the transcript shows the important parts of the session more cleanly. Try attaching a session transcript to your next PR so your teammate and their agent can review the provenance and prompting behind the change.

If you're up for an additional challenge, ask your agent to "exhaustively review all agent history in this repo and find where the SDLC is struggling or isn't agent-native". Using past sessions to recursively improve the agentic SDLC is a loop that we're using a lot today.

If you try it out, please let us know what you think!

18 comments

[ 3.8 ms ] story [ 52.7 ms ] thread
Building this made it obvious that there should be a standard format / specification for agent transcripts and logs (similar to ACP for runtime events). If you're interested in discussing this, please reach out!
I would love a service that I could upload these chats to (anonymously) so that those developing open models can have it as training data and not just the closed model companies. My understanding is that it’s very valuable, look what cursor have managed to train. Obviously some filtering so that only chats or projects you want to share get shared would need to be in order.
We have a private beta for a secure cloud version of the service, although its more geared towards teams/enterprise who want to share their work internally, rather than donating to open model developers. But interesting idea! I'm not very knowledgeable about crypto things, but I believe this is what people have considered "microtransactions" to be useful for.
I love this idea. I would totally upload my sessions if doing so helped train the next generation of open weight models. I'm using Claude to work on my free software projects so there aren't many secrets there anyway.
I often tell Claude Code to look at previous sessions in ~/.claude and it’s happy to jq/grep its way through them with no special tool. But being more efficient is always good.
Yes this is how we started as well!

At first I thought the main improvement would be that the search would be faster, but rg is already pretty freakin fast when the fs cache is warm.

What really ended up being the big efficiency improvement is the token efficiency. When you structure all of the transcripts in a SQL table, the agent can retrieve exactly what is needed (such as "print me the lite transcript, without the intermediate messages").

> Coding agents usually start from zero. They can inspect the current repo, but they often cannot recover the discussions, decisions, failed attempts, commands, and test results from earlier work.

Sure they can. Just ask them. Some (like Claude Code) even have built in tools for it that work a treat. It'll happily rebuild an entire edit history diff by diff.

This is true, maybe we could reword it to be less absolute.

The bigger point is that when they do go spelunking in the old session logs, it is extremely token inefficient, and you can often fill up an entire context window and force a compaction just by trying to put together a transcript or summary.

The goal here is less of doing something previously impossible, but doing it in a way that makes it so efficient and cheap that you can have agents do it very often, like before they start on every single task.

Very interesting project! I guess it could be even better if you didn't have to ingest the session data into a database but just build an index on top. I have an idea how to do it
Really nice idea - there is certainly gold in the history of agent actions. But how do you keep the ctx from trusting stale history?
The number of LLMs (and possibly very odd humans) replying to this thread is unusual.
yo this is crap. stop emailing people from the AUR using your stupid email handle to advertise your ai slop. the "we" you often mention is most likely you and that clanker producing this slop.