# Phoenix

- **Event:** [Agents in Context Toronto: a MongoDB Hackathon](https://cerebralvalley.ai/e/mongodb-toronto-hackathon)
- **When:** Sat, Nov 14 at 9:00 AM – 9:00 PM (EST)
- **Where:** Toronto, Canada
- **Team:** [Janvi Patel](https://cerebralvalley.ai/u/Janvipatel), [Ravin Kaur](https://cerebralvalley.ai/u/ravin123)
- **GitHub:** https://github.com/janvipatel18902/phoenix-hackathon.git
- **Demo video:** https://drive.google.com/file/d/1deoMrtooIZnV-F5iBwDMQ0oXoZlAwyx2/view?usp=sharing
- **Gallery:** https://cerebralvalley.ai/e/mongodb-toronto-hackathon/hackathon/gallery
- **Page:** https://cerebralvalley.ai/e/mongodb-toronto-hackathon/hackathon/gallery/7

Phoenix is an agent that finishes the job. It knows what actually happened across external systems, and completes the work after crashes, timeouts, lost state and API changes, without ever paying anyone twice.

THE PROBLEM
Real agent jobs span systems the agent doesn't control. Halfway through, the process dies, a refund times out and nobody knows if it went through, the agent's notes are gone, or a payments API changes format overnight. A naive agent stops, or repeats a payment.

OUR APPROACH
Phoenix never trusts its own memory. Before every external call it writes its intent to MongoDB, sends the call with a deterministic idempotency key, then asks the outside system what really happened. A task counts as done only when the system confirms it. After a crash it asks the systems, not its notes. If something can't be verified, or differs from what was expected (such as an amount), it hands it to a human instead of claiming success.

The core is deterministic Python: a task state machine, write-ahead intents, external verification, resume and reconcile. The LLM never executes anything. It only proposes a fix, which code validates and tests first.

THE DEMO
An event-cancellation agent cancels 8-10 tickets, refunds 8-10 attendees, emails them and releases the venue, across four mock systems we built. From the UI we inject chaos:
- A refund is applied but its response is lost, then we kill -9 the agent. On restart it reads reality, resends nothing, and the final count is exact.
- We wipe the agent's records. Reconcile rebuilds the job from what the systems report.
- The payments API changes format. The agent proposes an adaptation and tests it with a dry run that moves no money. A deliberately wrong fix (85 cents instead of 85 dollars) is rejected before anything is sent. The working fix is saved; the next run recalls it and still re-tests it.

HOW WE USE MONGODB ATLAS
- Multi-document transactions: a task's state change and its attempt record commit together.
- Unique indexes and compare-and-set updates: one task and one key per effect.
- Schema validation on tasks and attempts.
- Insert-only audit trail (attempts, effects): what we intended, sent and observed.
- An events collection, streamed over SSE, narrates every step.
- Atlas Vector Search over recovery memories (1024-dim embeddings from Atlas's hosted Voyage endpoint) recalls similar past API changes.

WHAT WE BUILT
Built in one day by two people: the engine, a mock world with chaos controls, an API, a UI, an adaptation validator and canary, and 101 automated tests. Verified on live Atlas with a real worker process: kill and resume with no duplicate refunds, wipe and reconcile, and an API change healed and reused in a second run.

HONEST LIMITS
The outside systems are mocks. Each task takes many Atlas round trips, so the demo uses a small event. Adaptation handles one API-change shape (payments refunds). The LLM is optional; a rule-based fallback proposes fixes without it.

## More from Agents in Context Toronto: a MongoDB Hackathon

- [Solo Spades](https://cerebralvalley.ai/e/mongodb-toronto-hackathon/hackathon/gallery/4)
- [Sharleen Chebet](https://cerebralvalley.ai/e/mongodb-toronto-hackathon/hackathon/gallery/5)
- [Musory](https://cerebralvalley.ai/e/mongodb-toronto-hackathon/hackathon/gallery/6)
- [MongoDB Larpers](https://cerebralvalley.ai/e/mongodb-toronto-hackathon/hackathon/gallery/8)
- [Sepi](https://cerebralvalley.ai/e/mongodb-toronto-hackathon/hackathon/gallery/9)
- [Retcon](https://cerebralvalley.ai/e/mongodb-toronto-hackathon/hackathon/gallery/10)

---

Markdown version of https://cerebralvalley.ai/e/mongodb-toronto-hackathon/hackathon/gallery/7. Site index for agents: https://cerebralvalley.ai/llms.txt · full text: https://cerebralvalley.ai/llms-full.txt
