Inspiration
What it does
AmanNgobrol — An Agent That Actually Remembers
Inspiration
Therapy works because of memory. A good therapist remembers what you said last week, notices the pattern you keep repeating, and gently brings it back up. But mental health apps often start from zero every session — and worse, they send your most vulnerable words to a cloud you don't control.
We wanted to build something different: an agent that remembers you, not just your session. A safe place to talk — hence Aman (safe) Ngobrol (chat) — where memory lives somewhere it can grow: searchable, semantic, structured, while the sensitive stuff stays as private as possible.
That's when we found CockroachDB. Not just a database to store rows in, but a memory layer — with vector indexes for semantic recall, and agent-ready tooling that let our AI actually talk to its own database.
What it does
AmanNgobrol is a private cognitive-behavioral-therapy workspace that runs an agentic memory loop:
- It remembers. Every chat turn retrieves what the agent already knows about you — fusing keyword full-text search, vector similarity, and weighted heuristics with Reciprocal Rank Fusion:
$$RRF(d) = \sum_{r \in R} \frac{1}{k + r(d)}, \quad k = 60$$
- It gets smarter on a schedule. Every six hours, EventBridge wakes the agent, it distills durable facts from recent sessions ("struggles with sleep-onset anxiety", "prefers morning sessions"), and writes them back as verified core memories with embeddings.
- It acts as a clinic of specialists. A master prompt turns the agent into a team of PhD-level therapists, triaged by problem type, age, and evidence-based modality (CBT, ERP, DBT, EMDR awareness).
- It's safe by architecture. Camera frames and audio stay on-device. BYOK keys never leave the device. LLM prompts carry zero PII. Crisis detection is on-device and fail-closed. "Delete my data" means gone — hard purge, irreversible.
How we built it
A monorepo: React 19 + Vite frontend (offline-first) and a TypeScript Lambda backend, with CockroachDB Serverless as the single source of truth.
The core is hybrid RAG over CockroachDB — heuristics plus to_tsvector full-text plus C-SPANN vector search (embeddings_vector_idx), fused per turn, grounding every reply in real memory. We leaned into all four CockroachDB agent-ready tools:
- Managed MCP Server — the agent introspects the cluster read-only, running
EXPLAINlive; - Distributed Vector Indexing — semantic memory inside the same cluster, no separate vector DB;
- ccloud CLI — wired into CI as a health gate;
- Agent Skills repo — 34 vendored skills encoding CockroachDB expertise.
Everything runs serverless on AWS — Lambda, S3, CloudFront, EventBridge, CloudWatch — and every LLM call is traced end-to-end into Arize Phoenix, prompts included.
Challenges we ran into
The demo makes it look smooth. It wasn't.
- The fake error bug. Every chat turn failed with a generic "Terjadi kendala teknis" while the health check said everything was fine. Root cause: the frontend wrapped the user's message in a punctuation-heavy prompt, and CockroachDB's
plainto_tsquerychoked on it — while the backend was returning the error as a fake assistant reply. We learned that an error channel must be structurally different from a content channel. - The hallucinating model. A small on-device model started looping on the word "Klinik" when faced with a long, complex therapist prompt. Prompt engineering isn't just about the model you use; it's about the model you have.
- The invisible bugs. Chat bubbles overlapped during streaming (framer-motion layout fighting the virtualizer). A telemetry exporter silently dropped every span because object spread killed the prototype. The free OpenRouter tier ran out mid-demo.
Each of these taught us the same lesson in a different disguise: the symptom is never the root cause.
Accomplishments that we're proud of
- 4/4 CockroachDB agent-ready tools live and working — not just listed in a README.
- A retrieval loop that genuinely feels like memory — the right memory surfaces even when the user says it in completely different words.
- Privacy as architecture, not a feature — zero PII in prompts, keys never leaving the device, hard purge that actually works.
- End-to-end observability — every LLM call traced to Phoenix with full prompts, so the agent's decisions are inspectable.
- A codebase that ships — 160+ tests, typecheck gates, CI health checks, and a deploy pipeline that actually deploys.
What we learned
Memory is not storage. Storing chat logs is the easy part; remembering means retrieving the right thing at the right time. A memory you can't retrieve is a memory you don't have.
An agent gets smarter on a schedule. The reflection loop taught us that memory isn't a snapshot — it's a process. The agent improves while you sleep.
Discipline beats cleverness. Systematic debugging, root-cause tracing, tests that reproduce the bug before the fix — every one of our hardest bugs cracked open the moment we stopped guessing.
What's next for AmanNgobrol
- Richer on-device intelligence — larger WebLLM models, plus local Ollama as a first-class fallback (we already integrated it).
- A therapy memory that maps over time — mood trajectories, goal progress, and relapse-pattern detection across sessions.
- Multi-region CockroachDB and OAuth2/OIDC auth for real multi-tenant use.
- A supervised "human-in-the-loop" mode — where a licensed therapist can review flagged sessions.
- More languages and cultural adaptation — because mental health is deeply personal, and so is the language you heal in.
How we built it
Challenges we ran into
Accomplishments that we're proud of
What we learned
What's next for AmanNgobrol
Built With
- amazon-web-services
- large-language-models
- node.js
- rag
- react
- serverless
- tailwind-css
- terraform
- typescript
- vite
- webassembly

Log in or sign up for Devpost to join the conversation.