The problem with building AI features
Most teams integrate LLMs directly — glue code, prompt templates, manual context injection. It works for demos. It breaks in production.- No memory — every conversation starts from zero
- No user isolation — concurrent users share state or fight over it
- No autonomy — agents only run when users ask
- Ops overhead — you own the infra, the retries, the scaling
What Kairn gives you
Per-user memory
Every user gets a persistent key-value store. The agent reads it at invocation time, writes to it during the session. Memory persists across conversations — no re-seeding required.
Soul-based identities
Define agent identities once. One soul serves all your users with zero shared state. Change the soul’s instructions and every user gets the update instantly.
Streaming out of the box
kairn.stream() yields typed events — tokens, tool calls, memory writes, done. Wire directly into your Next.js route and stream to the browser.Mandates — scheduled agents
Agents that run on their own. Cron-triggered, user-scoped, memory-aware. Weekly check-ins, daily reports, proactive nudges — without user interaction.
How it works
1
Create a soul
Define the agent’s identity, instructions, and tool access. One soul powers all your users.
2
Seed memory from your DB
Before each conversation, write user context from your database into the agent’s memory store. Name, plan, recent actions — whatever the agent needs to personalise.
3
Invoke or stream
Call
kairn.invoke() or kairn.stream() from your API route. The agent picks up context, runs, and writes what it learned back to memory.4
Read back what the agent wrote
After each turn,
memoryDelta tells you exactly what the agent updated. Sync it back to your own DB or surface it directly in your UI.Pick your path
Quickstart
From zero to your first agent invocation in under 5 minutes.
Core concepts
Souls, memory, sessions, mandates — the mental model explained.
SDK reference
Full API for every method, type, and error.
Use cases
Real product scenarios with working code you can adapt.