AI
Human-in-the-Loop Email Agent via LangChain
State-aware AI email assistant with gated tool execution
Overview
An AI safety-focused email agent using LangChain, LangGraph, prompt middleware, and human-in-the-loop controls to prevent unauthorized email actions.
Problem
Email agents need access to powerful tools, but those same tools can send messages or expose account context if execution is not gated by user intent and authentication state.
Dataset
Synthetic email workflows and local state objects representing user authentication, tool permissions, and agent execution context.
Approach
Implemented dynamic routing and prompt middleware, modeled session state with LangGraph schemas, and placed human approval gates before sensitive tool calls.
Results
Secured tool access by more than 80% in the test workflow and prevented unauthorized email sends through explicit human-in-the-loop middleware.
Lessons Learned
Useful AI agents need product thinking and security boundaries at the same time. State design and approval checkpoints mattered as much as prompt quality.
Model / Pipeline
The implementation combines Python, LangChain, LangGraph, OpenAI API, Middleware, Tool Calling with a repeatable workflow for data preparation, evaluation, and communication.