The eternal struggle of the modern developer is the inbox. You either miss critical GitHub review requests because you ignored a notification, or you drown in a sea of irrelevant solicitations and ads. A new design pattern published on DEV.to by noptium proposes a solution: hand off email monitoring to a long-lived AI agent that operates on a strict schedule, maintains state in a plain text file, and refuses to report anything unless it meets a precise three-way classification criteria. This isn't about building another chatbot; it's about creating a deterministic, read-only triage system that respects your attention.

The Architecture: Wake, Resume, Classify, Report

The core mechanism is deceptively simple. The agent wakes up on a scheduled interval (currently set to every 180 seconds in the author's production environment), reads a state.json file to determine the last checked timestamp, and fetches only emails newer than that marker. This ensures no duplicate processing and allows the agent to resume perfectly after restarts or downtime. The state file contains just two fields: last_checked_at in ISO 8601 format and a note string summarizing the latest scan. Crucially, the agent is read-only; it looks, judges, and notifies, but never modifies the mailbox or sends replies. This constraint is the safety net that makes delegation viable.

Why Two Categories Are Not Enough

Most triage systems fail because they rely on a binary important/unimportant split. This design introduces a third state: 'stay silent.' The classification rules are explicit. 'Report' covers GitHub review requests, deadline notices, and specific followed matters. 'Ignore completely' is for categories like job solicitations, ads, and routine service notifications; these are not just hidden, they are excluded from becoming task candidates. 'Stay silent' is the default for everything else, with one exception: personal requests with deadlines are always reported. This nuance prevents the 'just in case' noise that plagues other automation tools.

Operational Rules: State Over Events

Two hard-won operational rules elevate this from a script to a useful agent. First, the agent reports the current state of a GitHub PR (merged, closed, open), not the event that triggered the email (e.g., 'approved'). If the user has already merged the PR, the agent stays silent, avoiding redundant notifications. Second, if a review is needed, the agent prepares a draft following a style guide derived from past reviews, keying it to the PR head SHA. This draft is shown in chat but never auto-posted, keeping human judgment in the loop. The system logs every pass in an append-only last-scan.md file, providing an audit trail for why items were ignored.

Key Takeaways

  • Interval Trade-offs: The author started with 30-minute checks, moved to 1 hour, and settled on 180 seconds. Shorter intervals increase detection speed but also compute cost per pass.
  • Read-Only Safety: By restricting the agent to 'look and notify,' you eliminate the risk of accidental replies or deleted messages, lowering the barrier to adoption.
  • State Persistence: Using a local JSON file for state ensures the agent can recover from crashes without losing its place, a critical feature for long-lived processes.
  • Draft Preparation: The agent doesn't just alert; it pre-generates review drafts based on a style guide, reducing the cognitive load when you finally decide to act.

The Bottom Line

This design rejects the hype of autonomous AI agents that 'do everything.' Instead, it champions a constrained, observable, and deterministic agent that acts as a precise filter rather than a black-box assistant. If you are running long-lived agent environments, ditch the complex RAG pipelines for email triage and start with a state file and a strict silence policy.

Who Should Use This

This pattern fits developers who already run long-lived agent environments and struggle with both missed signals and notification fatigue. It is not for those seeking fully automated mailbox organization or those without a scheduled-run mechanism. The system requires initial setup of classification lists but offers a transparent, auditable way to reclaim your inbox. Start small: write the checklist, define the ignore categories, and let the timestamp drive the logic.