Shipped · 2026 to Present
Peptide AI RAG and Agent Platform
Hybrid retrieval, agent trajectories, and a privacy-safe semantic cache in production.
The problem
Users ask health questions that have to be answered from their own data, meaning their wearable signals, their logs, and their history, with no leakage between users, and it has to stream fast enough to feel like a conversation. At around 9 seconds to an answer, people stopped engaging with it.
What I built
A TypeScript retrieval stack on Supabase Edge Functions: hybrid dense + BM25 retrieval, Voyage cross-encoder reranking, streamed Claude responses, and a pgvector semantic cache scoped per user with dedicated safety guards.
Latency was the product problem
At around 9 seconds to a first useful answer, users stopped asking follow up questions. The thing that fixed it was not the choice of model. It was noticing how many questions were semantically similar to ones already asked. A pgvector cache keyed on embedding proximity absorbs those, and a cache hit returns in under 3 seconds at no extra inference cost.
Caching health questions safely
A simple shared cache would leak one user's data into another user's answer. Entries are scoped per user and gated by dedicated safety guards, and a Deno regression suite runs on every deploy to assert the negative controls, which are the questions that must never return a cache hit.
Separating computation from narration
The Coach system computes statistics deterministically in code, then asks the model only to narrate what was computed, citing evidence tiers. Numbers stop being hallucination surface area.
Grading the trajectory
Scoring only the final output hides the failures that matter. The evaluation covers claim level grounding, whether the tool trace was correct, and whether the agent abstained on negative controls. That means an agent that arrives at the right answer through the wrong tools still fails the suite.
Outcome
- ~70% latency reduction on cache hits (9s → under 3s) at $0 marginal cost
- 10,000+ downloads, +66% month over month
- 85K+ daily App Store impressions (+850%)
- Deno regression suite gates every retrieval change
Stack
Data flow
Retrieval + agent pipeline with privacy-scoped cache
- 1
Client
React / React Native / Capacitor, streamed tokens
- 2
Edge Function
Deno request handler, auth + RLS scoping
- 3
Semantic cache
pgvector nearest-neighbor, per-user scope, safety guards
- 4
Hybrid retrieval
Dense embeddings + BM25 over user-owned data
- 5
Rerank
Voyage cross-encoder over candidate evidence
- 6
Agent layer
Deterministic stats computation, then LLM narration
- 7
Claude
Streamed generation grounded in evidence-tiered citations
This diagram is generated from portfolio.ts. Edit the `architecture` field to change it.
Keep reading
SynthDrive
You describe a driving scenario in plain English, and it generates a 3D world, runs object detection on it, and scores how hard that scene is to perceive.
Case studyPanNote + PipelineEvolve
A Chrome extension that turns Panopto lectures into structured notes, plus a research harness that tries to improve the note pipeline automatically.
Case studyLegalLease
Hierarchical RAG over lease documents, plus a Qwen2.5-3B model I fine-tuned on clauses I pulled from real leases.
Case studyWant the deeper version of this?
I am happy to walk through the tradeoffs, the failure modes, and what I would do differently.