DEV Community

stmanst
stmanst

Posted on

Building a Self-Healing AI Agent: How I Automated My Entire Workflow with OpenCode Reminders

The Problem: AI Agents Forget Everything

Have you ever had an AI assistant lose context after a few hours? I run an AI agent on a VPS that manages my GitHub bounties, monitors PRs, and handles email notifications. The problem? It forgets everything between sessions.

The Solution: OpenCode Reminders Plugin

I built opencode-reminders — a plugin that gives AI agents persistent memory through reminders and mailbox integration.

What It Does

  • Scheduled Reminders: Set recurring or one-time reminders that wake up your AI session at the right time
  • Real-time Email Notifications: GitHub PR updates, reviews, and comments are pushed directly into your AI session as inline events
  • Self-Healing: If your SSH connection drops, reminders automatically resume when you reconnect
  • Session-Aware: Each session gets its own reminders and mailbox — no cross-contamination

Key Features

# Set a reminder that repeats every 2 hours
reminder_add when="every 2h" label="Check PR status"

# Create a Gmail-powered mailbox for your session
reminder_mailbox_start --name "GitHub" --gmail_label "GitHub"

# Mail arrives → AI sees it instantly
!ev mail:From: coderabbitai[bot]
PR #1501: nitpick comment on your code review
Enter fullscreen mode Exit fullscreen mode

How It Works

The plugin uses:

  • Gmail Plus Addressing (you+session@gmail.com) for per-session email isolation
  • IMAP polling every 30 seconds with SINCE filters for efficiency
  • Opencode's promptAsync to inject events directly into active sessions
  • Persistent JSON state that survives restarts

Real-World Results

Since deploying this plugin:

  • I never miss a PR review — email notifications arrive in my AI session within 30 seconds
  • I track 11+ open PRs across multiple repos with automated status checks
  • I hunt bounties on schedule without manual intervention
  • My AI agent works 24/7 even when I'm asleep

Open Source

The plugin is fully open source and works with any Opencode setup:

git clone https://github.com/truongsontung/opencode-reminders.git
cd opencode-reminders && bun install
Enter fullscreen mode Exit fullscreen mode

Configuration

{
  "plugin": ["/path/to/opencode-reminders/src/index.ts"]
}
Enter fullscreen mode Exit fullscreen mode

Set up Gmail credentials in ~/.opencode/mail-server/config.json and you're ready to go.

What's Next

I'm working on:

  • Multi-label email routing — different GitHub repos → different AI sessions
  • Smart email summarization — AI auto-categorizes and prioritizes notifications
  • Integration with Opire — automatic bounty tracking and claims

Try It Out

If you run an AI agent that needs to remember things, check out opencode-reminders on GitHub.

Star the repo if you find it useful!


Built with TypeScript, ImapFlow, and Nodemailer. Runs on any VPS with Node.js/Bun.

Top comments (0)