Hey everyone — wanted to share an architecture pattern that worked well for a recent production build, especially around preventing an agent from sending bad emails or corrupting CRM records.
The Problem
A revenue ops team had a shared inbox piling up with inbound leads. Simple LLM auto-responders were too risky because wrong pricing or duplicate CRM entries created more cleanup work than typing manually.
The Stack
- Orchestration: LangGraph (stateful graph with Postgres checkpointer)
- UI / Review Queue: Next.js dashboard + Slack interactive webhooks
- Tools: Typed CRM lookup/upsert tools + enrichment API
How the Graph Is Structured
- Ingest & Deduplicate: Normalizes the inbound thread and checks Postgres so duplicate webhooks don’t trigger double runs.
- Enrich & Match: Looks up sender domain and existing CRM contact/deal state using strict Pydantic input schemas.
- Draft & Interrupt (
interrupt_before): Generates the CRM field updates and a proposed reply, then hits a LangGraphinterruptbefore any write/send tool executes. - Human Approval Gate: Pushes a summary card to Slack and a lightweight Next.js review screen. A human approves, edits, or rejects, which resumes the thread from the Postgres checkpoint.
3 Guardrails That Saved Us in Production
- Hard per-thread token & step caps: Prevents retry loops when an upstream CRM API throws a 429 or 500.
- Read-only vs. Write tool separation: Enrichment tools run automatically; any tool that mutates CRM state or sends an email lives behind the
interruptboundary. - Full step audit log: Every tool input/output is logged to Postgres so when a prompt drifts, we can replay the exact state.
I wrote up the full breakdown, state flow, and lessons learned here if anyone is building something similar:
Full Inbox-to-CRM write-up on AgentCrafts
Happy to share the checkpointing setup or how we structured the Pydantic tool schemas if anyone is working through human-in-the-loop patterns in LangGraph!