
ctx.rs Indexes Months of AI Agent History in One Command, Cutting Token Costs 50x
Published by AINave Editorial • Reviewed by Ramit
Every developer who has worked with an AI coding agent knows the problem: you open a new session, re-explain the architecture, re-describe your patterns, and hope the agent does not repeat a mistake you debugged together last week. A new open-source tool called ctx treats that ritual as an engineering problem with an engineering solution. It is a Rust CLI that indexes months of session transcripts from multiple AI coding agents into a local SQLite database, enabling structured full-text search that uses roughly 50x fewer tokens than a raw transcript lookup.
What happened
ctx (pronounced "context," hosted at github.com/ctxrs/ctx) was released on July 4, 2026, by creator luca-ctx. It is a single Rust binary that discovers locally stored agent session logs from every supported harness and imports them into a local SQLite database. The supported agents currently include Claude Code, Codex, Cursor, Pi, OpenCode, Gemini CLI (via Antigravity), Factory AI Droid, and GitHub Copilot CLI.
Because each agent harness stores transcripts in its own proprietary format, ctx maintains a separate parser for each provider. The SQLite database normalizes all transcripts into sessions, events, metadata, and touched-file records. A full-text ranked search returns a matching event plus a configurable window of surrounding messages, rather than loading an entire session transcript.
The project's own benchmark measures the practical difference. A raw transcript search for a specific event consumes approximately 45,734 tokens. A structured ctx search for the same event returns approximately 917 tokens. That is a roughly 50x reduction in context consumed per history lookup.
Why AI builders should care
The agent context-amnesia problem is structural. Transformer-based models process a fixed token window at each inference call, and that window resets with every session. Even when context limits are not the bottleneck, loading months of raw session transcripts to answer a single question is prohibitively expensive.
In practice, this means agents avoid looking at past history unless explicitly told to. The gap is not capability but cost. An agent tasked with reading raw transcript files can consume enough tokens that the lookup itself triggers context compaction, leaving little room for the actual work. ctx changes the economics: at roughly 917 tokens per search result, an agent can check relevant history before every significant task and have budget left for the task itself.
The creator described the team's own experience on Hacker News: agents encountering a failed CI test suite would assume it was a test regression and spend many turns chasing phantom bugs. After ctx was set up, the same agent searched prior session history, recognized that the same failure had appeared before, and went directly to the cleanup runbook. "It's a boring story," the post reads, "but it's real agent productivity."
Practical implications
ctx runs entirely locally. It does not send transcripts, prompts, or indexed history to any cloud service, does not call model APIs, and does not require API keys. All data stays in a single file on the developer's machine. SQLite is embedded in the ctx binary itself, so no background service or configuration is needed.
For agent-native use, an optional skill can be added to Claude Code, Cursor, and Codex via the open skills installer. The skill instructs the agent to run a history search before beginning work in any area. ctx also ships an MCP (Model Context Protocol) server interface, meaning it can be called as a tool from any MCP-compatible harness without per-agent skill installation. SDKs exist for TypeScript, Python, Rust, Go, JVM, Swift, and .NET.
The creator recommends treating session history as "anthropology": a record of what happened, not necessarily the ground truth. Canonical decisions belong in specifications and documentation. Session history is useful for understanding why something was built or why a pattern was rejected, but it should not override actively maintained project files.
Caveats
The project reveals an important upstream problem: there is no shared schema for coding agent session logs. Each provider stores transcripts in its own format, which is why ctx requires a separate parser for each of the eight supported harnesses. The creator called for a specification analogous to the Agent Communication Protocol for runtime events. The contracts/agent-history-v1 directory in the ctx repository suggests the team has already begun drafting a proposal. The NIST AI Agent Standards Initiative, launched in February 2026, is soliciting input on exactly this category of interoperability gap.
A cloud version is in private beta for teams who want to share session history internally. The creator acknowledged in the HN thread that privacy boundaries around shared transcripts are still being worked out, since transcripts may contain personal details alongside technical decisions.
ctx does not compete with semantic memory tools like Mem0, Zep Graphiti, or Letta, which extract compact facts from conversations. It targets the episodic record: what actually happened during previous sessions, including debugging dead-ends, rejected approaches, and the runbook that resolved the CI failure. For builders shipping AI development tools or agent workflows, ctx offers a practical, local, and open-source approach to making agent history retrievable at a cost that enables routine use.
FAQs
What is ctx.rs and how does it fix agent context amnesia?
ctx.rs is an open-source Rust CLI that indexes AI agent transcripts locally into a SQLite database and enables structured full-text search. It fixes agent context amnesia by reducing history-lookup token usage: a raw transcript search consumes approximately 45,734 tokens while a ctx search returns the same result in approximately 917 tokens, a roughly 50x reduction. This makes it affordable for agents to check past history before every task.
How does ctx store and index AI agent transcripts locally?
ctx imports transcripts from multiple agent harnesses into a single local SQLite database file. The database normalizes sessions, events, metadata, and touched-file records into a consistent schema. Searches use full-text ranked matching that returns a specific event and a configurable window of surrounding messages, rather than loading an entire session transcript.
What providers does ctx support for transcript importing?
ctx currently supports eight agent harnesses: Claude Code, Codex, Cursor, Pi, OpenCode, Gemini CLI (via Antigravity), Factory AI Droid, and GitHub Copilot CLI. Each requires a separate parser because there is no shared schema for coding agent session logs.
How much token efficiency improvement does ctx offer?
The project's benchmark shows a reduction from approximately 45,734 tokens for a raw transcript search to approximately 917 tokens for a structured ctx search. That is a roughly 50x reduction in context consumed per history lookup.






















