# BlackBox

- **Event:** [The Persistent Context Sprint Hackathon | Live at MongoDB .Local Build Fest](https://cerebralvalley.ai/e/persistent-context-sprint-hackathon)
- **When:** Thu, Aug 13 at 12:30 – 8:00 PM (PDT)
- **Where:** Pier 48, San Francisco, CA
- **Team:** [Laksh Goyal](https://cerebralvalley.ai/u/lakshgoyal), [Bryan Pham](https://cerebralvalley.ai/u/branpham), [Sukhman Cheema](https://cerebralvalley.ai/u/Sukhman12), [Neel Majmudar](https://cerebralvalley.ai/u/neelmajmudar)
- **GitHub:** https://github.com/lgoyal6/MongoHack
- **Demo video:** https://youtu.be/OseH8j57FMU
- **Gallery:** https://cerebralvalley.ai/e/persistent-context-sprint-hackathon/hackathon/gallery
- **Page:** https://cerebralvalley.ai/e/persistent-context-sprint-hackathon/hackathon/gallery/81

One in seven New York EMS calls turns out to be something other than what it was dispatched as. We measured it: across ~30 million (29,978,154) NYC EMS incidents, ~900,000 (845,887) of the ~6 million (5,653,498) calls since 2023 closed under a different call type than they were dispatched under. Every one is a labeled case where the first read was wrong, and the reasoning behind the correction was never recorded anywhere.

BlackBox is a voice-native flight recorder for EMS crews. During a live call it listens to the medic over an earpiece, captures the decisions they make and the reasons they give, writes those to MongoDB Atlas as embedded documents, drafts the patient care report at transfer of care, and retrieves that reasoning on the next similar call to brief the next crew. Every incident-response tool on the market stores what happened. None store what the human decided and why. That reasoning currently dies in radio chatter, and voice is the only capture medium that gets it, because during an active call nobody is typing.

MongoDB Atlas is not our database. It is the entire runtime. We took the single-platform constraint literally: memory, state, context, retrieval and transport all run on one cluster. No Redis, no Kafka, no Pinecone, no broker anywhere in this stack.

Retrieval is one aggregation pipeline, not three round trips. A single $vectorSearch fans out across decisions, postmortems and runbooks with $unionWith, capturing {$meta: "vectorSearchScore"} inside each sub-pipeline, then fuses the three result sets with reciprocal rank fusion. Fusing by rank rather than raw score is deliberate: cosine distributions are not comparable across collections, and sorting a union by score systematically buries decision memory under the clinical corpus, which is exactly the signal this product exists to surface. A fourth collection, remediations, is queried separately so that failure memory can actively exclude routes that cost time on previous runs.

MongoDB is also our event bus. Any process, a route handler, the worker, a one-off script, inserts into an events collection; the dashboard opens a change stream on it and pushes each insert to the browser over SSE. Replay after a reload is a plain find(), multi-process coordination needs no IPC, and every number a judge sees on screen arrived over an Atlas change stream. Sequence numbers come from a single server-side $inc inside findOneAndUpdate, verified gap-free and duplicate-free under 200 concurrent emits.

Change streams are the trigger too. A worker watches incidents for live inserts and fires the graph, persisting its resume token after each handled event, so an incident inserted while the worker is down is still processed on restart. We drilled that rather than assuming it.

And Atlas is the crash-safety story. LangGraph checkpoints to MongoDBSaver, so the graph parks at interrupt() on the drug-dose readback gate with its durable state in Atlas. Mid-demo we kill the process in front of the judges and restart it, and the agent resumes the call exactly where it left off. That is impossible with an in-memory checkpointer, and it is the part of the demo hardest to fake.

Underneath: four Atlas Vector Search indexes at 1024 dimensions across decisions, remediations, runbooks and postmortems, a server-side JSON Schema validator that rejects any decision document missing a rationale, a TTL index so rehearsal runs self-clean, and a projection that quarantines ground truth so no retrieval path or graph node can read the answers.

VoyageAI does the semantic work. voyage-3-large embeds our decision corpus and 183 chunks of NASEMSO national clinical guidelines, ingested live. Semantic retrieval is what makes the second demo call land: it is dispatched as general illness rather than unconscious, so a string lookup finds nothing and vector search visibly earns its place. Voyage being MongoDB-owned meant one fewer provider and one consistent 1024-dimension contract across all four indexes.

ElevenLabs is why this is a product and not a dashboard. Seven server tools hit our own route handlers and write to Atlas mid-call, so the agent does real work instead of reading pre-generated text. Barge-in is on, the tone shifts from calm during the brief to clipped when confirming anything irreversible, and every drug and dose passes an aviation-style readback the agent must speak verbatim before anything is written. That readback doubles as the LangGraph human-in-the-loop gate, which is a genuinely satisfying place for two sponsor technologies to meet.

LangChain and LangGraph gave us durable interrupts that survive a process kill, turning a clinical safety requirement into the best fifteen seconds of the demo.

The agent never proposes a treatment, dose or diagnosis. It recalls what happened last time, reads back what the medic said, and quotes retrieved guidance with attribution. The human owns every clinical judgment.

---

Markdown version of https://cerebralvalley.ai/e/persistent-context-sprint-hackathon/hackathon/gallery/81. Site index for agents: https://cerebralvalley.ai/llms.txt · full text: https://cerebralvalley.ai/llms-full.txt
