The cloud is leaking your secrets, and Ewan Dkhar has had enough. In a new submission for the Hacktoberfest Open-Source AI Challenge, the developer released "Local Email Agent," a privacy-first inbox assistant that runs entirely on a local workstation. By leveraging Google's open-weight Gemma 2 9B model via Ollama, the tool eliminates the need to route sensitive email metadata through proprietary APIs, effectively solving the "executive function black hole" of modern email management.
The Sloth Protocol: Privacy Over Convenience
Dkhar's motivation wasn't just laziness; it was a near-miss with a scholarship verification deadline buried in an administrative newsletter. The agent addresses this by connecting to IMAP, stripping HTML clutter, and using Gemma 2 to categorize messages into actionable tiers like "action_needed" or "low_priority." Crucially, the architecture ensures zero email data leaves the machine, offering a stark contrast to cloud-based assistants that often require extensive data permissions.
ReAct Loops and Human-in-the-Loop Safety
The system doesn't just sort; it drafts. Using a ReAct (Reasoning + Acting) co-pilot, the agent analyzes thread context to generate replies. However, Dkhar implemented a strict "human-in-the-loop" protocol. The AI queues drafts for review, requiring explicit user approval before dispatching over authenticated SMTP. This design choice acknowledges that while automation is efficient, autonomy without verification is a liability in professional communication.
Technical Stack: Ollama, FastAPI, and SQLite WAL
Built on Python 3.12 and React 18, the stack relies on Ollama for inference with temperature tuned to 0.2 for classification stability. The backend uses SQLite in Write-Ahead Logging (WAL) mode for robust local storage, while defensive prompt sanitization neutralizes injection vectors from untrusted incoming emails. The entire pipeline is containerized with Docker Compose, making deployment on consumer hardware surprisingly straightforward for those willing to configure their IMAP and SMTP credentials.
Key Takeaways
- Zero-Cloud Privacy: All email processing occurs locally via Ollama, ensuring no data leaves the user's machine.
- Open-Weight Power: Uses Gemma 2 9B, proving that 9B parameter models are sufficient for nuanced triage and drafting.
- Safety First: Implements a mandatory human approval step before sending any AI-drafted response.
- Defensive Coding: Includes specific sanitization against prompt injection from incoming email content.
The Bottom Line
This project is a masterclass in "lazy" engineeringβsolving a high-friction problem with minimal cognitive load. It proves you don't need enterprise-grade AI to automate your life, just the right open-weight model and a healthy distrust of the cloud.