Catch duplicate customer replies from a self-scheduled AI inbox agent with run counts, claim rows and a heartbeat
A solo operator let his agent write its own cron line for an AI email-reply job. It ran 6,048 times in three weeks and answered 12 emails six times each. He lists the fixes: claim a window first, a unique key, a lock, and alerts on missing runs.
Evidence: The source shows its work: steps, screenshots, code or data you can inspect.
The business problem
An AI agent that answers customer email on a schedule can fail silently or send the same reply many times. A one-line schedule looks harmless in review, and normal error alerts never fire because every bad run exits successfully.
What was tried
1. The author's agent proposed a crontab line to run an inbox-reply script every five minutes, and he approved it without working out how often it would run. 2. For the first four days every run died at once (wrong working directory and no environment file under cron), and output was sent to /dev/null, so nobody noticed until a customer asked. 3. After fixing paths and adding a wrapper script with strict shell settings and timestamped logs with exit codes, the job started replying. Each model call took 40 to 90 seconds and the 'replied' flag was only set after sending, so overlapping runs read the same unanswered messages: 12 emails got 72 replies. 4. Fixes, in the order he rates them: insert a row that claims the time window before doing any work (skip if the row already exists), and add a unique constraint on replies per message; use flock as a second guard on the same host; write the schedule as runs per day and count real runs from the log; add a random delay so jobs do not all fire at the same second; alert when a heartbeat file goes stale and when a run takes over three times the median; move real work to systemd timers, which will not start a second copy while one is running, and check the calendar expression with systemd-analyze. 5. The script now prints its own runs-per-day figure at startup, so each deploy logs a number to check.
What was reported (mixed)
The author reports 6,048 runs over three weeks, four days of silent failure, and 72 replies sent for 12 customer emails before a customer flagged the duplicates. He says the fix is about forty lines and that the self-reported runs-per-day line has since caught two bad schedules before they shipped. No later error rate or customer impact figures are given.
Limitations
Vendor: the author ends the post by selling a paid agent playbook. Self-reported incident with no logs beyond the snippets shown. The model and mail provider are not named. The setup is a small self-hosted server (a Raspberry Pi is mentioned), so the systemd and flock advice assumes Linux. The author posts near daily in a dramatic incident format, which carries some risk that details are simplified.
What you need
A scheduled script that calls a language model to answer email, a database that records replies, and a Linux host with cron or systemd.
Before approving any schedule an agent writes, convert it to runs per day and compare that with what you meant. Then count actual runs in the log a day later.
Sources
- DEV Community (ulnit) ↗ Vendor case study, published November 7, 2026
Source published: November 7, 2026. Last reviewed here: November 18, 2026. Spot a mistake? Tell us.
Tools in this workflow
- systemd: Timers that will not start overlapping runsTry systemd
Get new workflows like this by email
A short selection of the most useful new workflows, including the ones that did not work. Free, and you can unsubscribe at any time.
Related workflows
Design a support email agent that sends only safe answers, drafts the rest, keeps a human copy of every email, and gets tested with hostile mail before it can send
A solo app founder built a support agent that answers known how-to questions and drafts everything else for him. The rules came first: a fixed escalation list checked outside the model, a copy of every email to him, and a hostile-email test that exposed a false pass.
Replace a support agent's list of 'never' rules with positive rules that name a data source and an exact fallback, then measure on 400 real messages
A solo operator found his support agent refusing simple return questions because of 23 prohibitions in its prompt. He rewrote them as nine rules, each with a data source and a fallback, and cut wrongful refusals from 14.2 to 1.2 percent on a test set.
Run a long-lived SaaS behind the scenes with cheap script checks first, agents second, and findings filed as tasks instead of alerts
The owner of a 16-year-old affiliate site builder describes how small agents now watch servers, triage support and work the bug list: scripts catch problems, agents investigate, findings go on a deduplicated task list, and risky actions are blocked in code.
Stress-test support email routing at category boundaries, then separate urgency rules from AI sentiment
An easybits builder describes testing an n8n Gmail-to-Slack router with 50 difficult emails. Polite outages, mixed languages and overlapping categories exposed failures that confidence scores alone missed.