AI that forgets is just autocomplete. Contexara gives your agent a memory it can build on.
Project description
Contexara
AI that forgets is just autocomplete. Contexara gives your agent a memory it can build on.
Persistent, three-tier memory layer for AI agents. Drop it in and your agent remembers facts, preferences, and past sessions — automatically, across every conversation.
Install
pip install contexara
contexara setup
contexara ask "what was I working on?"
For specific providers:
pip install contexara[openai]
pip install contexara[anthropic]
pip install contexara[gemini]
pip install contexara[all-providers]
How It Works
| Tier | What | Scope |
|---|---|---|
| T1 — Raw Turns | Every user/assistant message, stored verbatim | Current session |
| T2 — Episodes | LLM-crystallized summaries of past sessions | Cross-session |
| T3 — Semantic Memory | Extracted facts, preferences, constraints, corrections | Permanent |
On every query, all three tiers inject context automatically — your agent is never blind.
Supported Providers
| Provider | CONTEXARA_PROVIDER value |
|---|---|
| AWS Bedrock | bedrock (default) |
| OpenAI | openai |
| Anthropic | anthropic |
| Google Gemini | gemini |
| OpenRouter | openrouter |
Configure via contexara setup or manually in ~/.contexara/.env:
CONTEXARA_PROVIDER=openai
CONTEXARA_MODEL=gpt-4o
OPENAI_API_KEY=sk-...
Python SDK
from contexara import ContextaraClient
from contexara.llm import call_llm
mem = ContextaraClient(namespace="my-agent")
while True:
user_input = input("You: ").strip()
if user_input.lower() in ("exit", "quit"):
mem.flush() # extract memories from remaining turns on exit
break
prompt = mem.build_prompt(user_input) # retrieve + enhance (T1+T2+T3)
reply = call_llm(prompt)
print(f"Assistant: {reply}")
mem.ingest(user_input, reply) # store turn + batch extract every 10 turns
Additional SDK Methods
mem = ContextaraClient(namespace="my-agent")
# Explicit memory operations
mem.store("User prefers bullet-point responses", kind="preference")
mem.retrieve("what does the user prefer?") # returns [{content, kind}, ...]
mem.search("budget constraints") # returns full records with metadata
mem.stats() # memory counts by kind and source
mem.checkpoint() # force crystallize current session
mem.history(memory_id) # version history for a memory
CLI Reference
| Command | Description |
|---|---|
contexara setup |
Configure AI provider credentials |
contexara ask "<query>" |
Single query with full memory context |
contexara chat |
Interactive chat mode |
contexara store "<text>" |
Save a memory directly |
contexara list |
List stored memories |
contexara search "<query>" |
Semantic search over memories |
contexara stats |
Memory counts by kind and source |
contexara consolidate |
LLM-merge overlapping memories |
contexara clear |
Delete all memories in namespace |
contexara namespace list|create|switch|delete |
Manage namespaces |
contexara serve |
Start REST API server |
contexara dashboard |
Start web dashboard |
contexara mcp |
Start MCP server |
Namespaces
Complete data isolation between agents or projects:
contexara namespace create work
contexara namespace switch work
contexara ask "what are my pending tasks?" --namespace work
Key Features
- Local first — all data in
~/.contexara/, no cloud required - LLM agnostic — Bedrock, OpenAI, Anthropic, Gemini, OpenRouter
- Batch extraction — memories extracted every 10 turns for cost efficiency, flushed on exit
- Intent classification — detects historical vs. recent vs. semantic queries, adjusts retrieval strategy
- Hybrid retrieval — FTS5 + cosine vector search with RRF fusion
- Multiplicative scoring — memory ranked by similarity × importance × recency, per-kind decay
- Memory observability — tracks which memories were cited, usage ratio, and confidence signals per turn
- Session continuity — sessions crystallize after 60 min inactivity, injected on next session start
- Never-delete versioning — full history of every memory update
- Cold archive — turns older than 30 days auto-swept to FTS5-searchable archive
- MCP server — plug into Claude Desktop or any MCP-compatible framework
- Web dashboard — memory browser, session explorer, latency charts, LLM-as-judge evals
Data Storage
~/.contexara/
├── memory.db # T3 semantic memories
├── active_state.db # T1 raw turns + T2 episodes + sessions
└── cold_archive.db # archived turns older than 30 days
Built by Prajwal Narayan
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file contexara-2.4.0.tar.gz.
File metadata
- Download URL: contexara-2.4.0.tar.gz
- Upload date:
- Size: 913.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e0a13c4af418ab6ae076d39f8c752cab8265f4fd4dc642c506d0079c15ba485
|
|
| MD5 |
670a943622aaae3e4ca9447c1eb27978
|
|
| BLAKE2b-256 |
d27404f33d54cdc4c9c1323d286ba91c7df0ec0fe310b2829b1115be12158832
|
File details
Details for the file contexara-2.4.0-py3-none-any.whl.
File metadata
- Download URL: contexara-2.4.0-py3-none-any.whl
- Upload date:
- Size: 906.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc7cbfaafdb467225bacde25a15ff8d2d17a4d686bf3d9900fe042e147fa4e29
|
|
| MD5 |
d7dd73b89a87200ece0dad4605354c7c
|
|
| BLAKE2b-256 |
305c6848f785e87e321e7715bc72fd0488237d4cb723a264d62a24f4dc21a012
|