A standalone context policy engine for AI agents
npm install kata-context> Status: v0.2.0 (Database + Storage Layer) — Storage foundation complete. Building in public.
Kata Context is a standalone context policy engine for AI agents. It manages what goes in and out of the LLM context window — handling compaction, summarization, retrieval, and budget-aware windowing. Framework-agnostic: works with any agent system, or none.
Part of the Kata ecosystem, alongside Kata Orchestrator, Kata Agents, Kata Context.
Policy, not storage. Given messages and a context budget, determine the optimal window to send to the model. The value isn't persisting conversations — it's intelligently managing finite context.
Kata Context answers ONE question: "Given this conversation history and this token budget, what's the optimal context window to send?"
It doesn't care about:
- Which LLM you're using
- How your agent is structured
- What tools you have
- How you handle responses
```
┌─────────────────────────────────────┐
│ Your Agent Code │
│ (LangChain, custom, Kata, etc.) │
└─────────────────┬───────────────────┘
│ "What should I send?"
▼
┌─────────────────────────────────────┐
│ Kata Context │
│ - Stores full history │
│ - Applies policy │
│ - Returns optimal window │
└─────────────────┬───────────────────┘
│ Optimized context
▼
┌─────────────────────────────────────┐
│ Any LLM │
│ (OpenAI, Anthropic, local, etc.) │
└─────────────────────────────────────┘
| Aspect | Framework (Letta, LangChain) | Infrastructure (Kata Context) |
| ---------------- | ---------------------------- | ----------------------------- |
| Relationship | You build inside it | You call it from outside |
| Control | Framework controls lifecycle | You control lifecycle |
| Opinions | Dictates agent patterns | No opinion on agent design |
| Coupling | Tight — hard to leave | Loose — easy to swap |
| Analogy | Rails | Postgres |
REST API for context management with token-budgeted retrieval:
`bashCreate a context
curl -X POST https://your-app.vercel.app/api/v1/contexts \
-H "Content-Type: application/json" \
-d '{"metadata": {"agent": "my-agent"}}'
SDKs for Python and TypeScript coming in v0.3.0.
Development
`bash
Install dependencies
pnpm installRun tests (87 tests, 100% coverage)
pnpm testLint and format
pnpm checkDatabase commands
pnpm db:generate # Generate migrations
pnpm db:migrate # Apply migrations
pnpm db:studio # Open Drizzle StudioBuild
pnpm build
``Stack: TypeScript 5.9, pnpm, Biome, Vitest, Drizzle ORM, PostgreSQL (Neon), pgvector, Vercel serverless
- [x] v0.1.0 — Core Setup (TypeScript, linting, testing, CI)
- [x] v0.2.0 — Database + Storage Layer (PostgreSQL, repository pattern, REST API)
- [ ] v0.3.0 — Policy engine (compaction, forking, semantic retrieval)
- [ ] v1.0 — Hosted API with multi-tenancy
Apache 2.0 (core engine and SDKs)