Skip to content
cd ..~/abhay/projects/autonomail.md · 5.2K · case study 06 of 09

9 files open · click a tab, or use prev / next at the bottom of the page

// case 06 — Multi-agent system · 2026

Autonomail.md

A multi-agent system that plans, writes and runs email campaigns, with a human approving every send.

> Live at autonomail.dev: a LangGraph pipeline from brief to send, paused for human approval.

MY ROLESolo build: agents, backend and frontend
TIMELINEApr — Jun 2026
TEAMJust me
STACK
LangGraphLangChainGemini 2.5 Flash LiteFastAPIMongoDBNext.js
autonomail.dev · campaign · pending approval
$ start campaign "spring launch"
OK parse_brief product · audience · goal
OK segmentation RFM micro-segments, scored
OK strategy send times · A/B variants
OK content_generation subject + body per variant
WAIT approval PENDING_APPROVAL · waiting for you
graph paused · state checkpointed in MongoDB
OK approved → execution · sends scheduled
$
PIPELINE
1Brief
2Segments
3Strategy
4Content
5Approval
6Send
GRAPH NODES6
RETRIES3 / node
LLMGemini 2.5
a human approves every send
// 01 — context

the problem_

cat problem.md

Running an email campaign is a chain of judgement calls: who to target, what to say to each segment, when to send, which variant to test. One prompt can't do all of that well, and nobody wants an AI sending email to real customers on its own.

Autonomail splits the work across specialised agents in a directed graph and stops at an approval node, so a person reviews the plan and the copy before anything is sent.

## constraints
  • Human approval before send
  • Long-running pipeline
  • Retries without double sends
  • Natural-language briefs
  • Live progress in the UI
  • Cheap LLM calls
./my-role.sh --verbose

abhay@os ~ % what did I actually do?

  1. 01Designed the LangGraph StateGraph: parse brief, segmentation, strategy, content generation, approval and execution.
  2. 02Built segmentation on real RFM scoring: micro-segments with priority scores and a messaging approach each.
  3. 03Wrapped every node in a runner that checkpoints state to MongoDB, records the current step and retries up to 3 times with exponential backoff and a fallback.
  4. 04Built the FastAPI backend: the pipeline runs as a background task and the frontend polls a status endpoint for a live progress tracker.
  5. 05Built the Next.js multi-step brief form and the approval screen, and deployed it at autonomail.dev.

[ ok ] exit 0 · 5 tasks · owner: abhay

// 02 — results

what moved_

Three numbers I'd put on a slide. Measured in production, not in a benchmark I wrote the night before.

AGENTS6graph nodes, brief to sendParse, segment, strategise, write, approve, execute.
RETRIES3per node, exponential backoffWith a fallback when the model keeps failing.
LIVEautonomail.devdeployedFastAPI backend, Next.js frontend, MongoDB Atlas.
// 03 — architecture

how it fits_

Each agent does one job and hands typed state to the next. The approval node is a real pause in the graph, not a confirm dialog.

open architecture.excalidraw — autonomail
FRONTEND
Brief formNext.js · shadcn/ui
Progresspolls every 4 s
REST
API
FastAPI/api/v1/campaigns
Background taskasyncio
graph
AGENTS
Parse → SegmentRFM
Strategy → ContentA/B variants
Approvalpauses graph
state
DATA
MongoDB Atlascheckpoints
Campaign APIexecution
request / write pathresponse / events backnothing sends without approval
// 04 — key decisions

git blame me_

adr-001.md
CHOSE

A graph of specialised agents

REJECTED

One big prompt

TRADE-OFF

More moving parts, but each step can be retried, inspected and improved alone.

adr-002.md
CHOSE

Checkpoint before every node

REJECTED

Holding state in memory

TRADE-OFF

A write per step, but a crash or retry resumes from the last good state.

adr-003.md
CHOSE

Polling for progress

REJECTED

WebSockets

TRADE-OFF

Up to 4 s of lag, but simple to host and impossible to desync.

// 05 — under the hood

the good bit_

vim backend/app/orchestration/campaign_graph.pyPython
1async def _execute_node_with_retries(node_name, state, operation, fallback=None):
2 """Run a node with checkpointing, retries, state validation, and persistence."""
3 for attempt in range(1, MAX_RETRIES + 1):
4 try:
5 await manager.create_checkpoint(state, current_node=node_name)
6 next_state = await operation(CampaignState(**dict(state)))
7 if not manager.validate_state(next_state):
8 raise ValueError(f'State validation failed at node={node_name}')
9 await manager.save_state(next_state, next_state['campaign_id'])
10 return next_state
11 except Exception as exc:
12 last_error = exc
13 if attempt < MAX_RETRIES:
14 await asyncio.sleep(2 ** (attempt - 1))
15
16 failed_state = _append_error(state, f'{node_name} failed after {MAX_RETRIES} retries: {last_error}')
17 if fallback is not None:
18 failed_state = fallback(failed_state)
19 await manager.save_state(failed_state, failed_state['campaign_id'])
20 return failed_state
NORMAL backend/app/orchestration/campaign_graph.py20 lines · utf-8

Every agent runs through this: checkpoint first, validate and save the new state, retry with backoff, and fall back if it keeps failing.

less lessons.txt

If I built it again, I'd change…

  1. L1Put the human in the graphApproval as a node made pausing, resuming and auditing natural instead of bolted on.
  2. L2Surface the current stepWriting the running node to the campaign record turned a black box into a progress bar.
  3. L3Every node needs a fallbackA cheap model fails sometimes. A sensible default keeps the campaign moving.

lessons.txt (END) — press q to quit

// 06 — timeline

git log --since_

Apr — Jun 2026

git log --reverse --format=milestone autonomail
  1. 01Apr 2026GraphAgents, state and the LangGraph pipeline.
  2. 02May 2026BackendFastAPI, MongoDB, retries and checkpoints.
  3. 03Jun 2026Frontend + deployBrief form, approval screen, autonomail.dev.
cd ~/work./contact — itsabhay@abhay.si