Skip to content
Blog / News

AgentMail + HydraDB: Persistent AI Agent Memory for Your Inbox

Binoy Perera

Sync AgentMail inboxes into HydraDB so your AI agent can recall past email, threads and attachments before it replies. Setup takes one command.

  • hydradb
  • ai-agent-memory
  • integrations
  • agent-inbox

TL;DR

AgentMail now integrates with HydraDB, the open-source context and memory layer for AI agents. A small Python connector syncs your AgentMail inboxes into HydraDB, so your agent can search its past email before it replies, with threads and reply chains kept intact. Setup is one pip install, three environment variables and one sync command.

Email is where an agent's working history piles up. The price a customer accepted, the contract version they signed off on, the follow-up they asked for three weeks ago: it all sits in the inbox. Most agents only ever see the message in front of them, though. Each run starts cold, and anything outside the current thread is invisible unless you build retrieval yourself.

Today we're shipping an integration with HydraDB that gives your agent persistent memory over its inbox. HydraDB is a context and memory layer for AI agents, built as an open-source graph database. The hydradb-agentmail-plugin connector syncs an AgentMail inbox into HydraDB as an app source. When your agent asks "what pricing did we agree on?", it gets back the email that answers the question along with the conversation around it.

What does the AgentMail and HydraDB integration do?

The connector copies the email in your AgentMail inboxes into a HydraDB database. Your agent still sends and receives through AgentMail exactly as before. HydraDB is where it searches when it needs to remember something from an older thread. You can sync a single inbox or every inbox on your account.

For each message, the connector stores:

  • The subject and body text, plus sender, recipients, labels and attachment names and types
  • A link to its thread, and a link to the message it replied to
  • The inbox and thread IDs as metadata, so you can scope recall to one agent's mail

Messages are keyed on their RFC Message-ID. Running the sync again updates a message instead of duplicating it, and reply links still connect when the parent and the reply arrive in different sync runs.

What can you build with agent email memory?

Support agents that check history first. Before answering a ticket, the agent pulls the customer's earlier threads and sees what was already promised, tried or escalated.

Sales and ops agents that remember terms. Quotes, delivery dates and agreed exceptions live in email. The agent can recall them by meaning ("what discount did Acme get?") rather than by exact subject line.

Assistants that run for weeks. Synced email stays searchable across agent runs, so an assistant that wakes up on a schedule picks up where it left off. If you're already using HydraDB for Slack, docs or a CRM, email becomes one more source in the same query.

How do I set up AgentMail with HydraDB?

You need an AgentMail account with an API key (free to start), a HydraDB account with an API key and a target database, and Python 3.9 or later.

Install the connector:

Bash

pip install hydradb-agentmail-plugin

Set your keys and the HydraDB database to write into:

Bash

export AGENTMAIL_API_KEY="your-agentmail-key"export HYDRADB_API_KEY="your-hydradb-key"export HYDRADB_DATABASE="your-database"

Sync every inbox on the account, or pass one inbox to scope it:

Bash

agentmail-syncagentmail-sync agent@agentmail.to

Then query HydraDB. With query_apps on (the default), synced email is searched alongside any other app sources in the database:

Bash

curl https://api.hydradb.com/query \  -H "Authorization: Bearer $HYDRADB_API_KEY" \  -H "API-Version: 2" \  -H "Content-Type: application/json" \  -d '{"database": "your-database", "query": "what pricing did we agree on?", "query_apps": true}'

Results come back with the source email and its thread and reply relationships, ready to drop into your agent's prompt.

How do I keep the agent's memory current?

There are two options, and most teams use both.

For backfill, run agentmail-sync on a schedule. Set AGENTMAIL_AFTER to an ISO 8601 timestamp to pull only messages after a cutoff, which keeps each run incremental.

For real-time memory, ingest each email as it arrives. Subscribe to the message.received and message.sent webhook events and call the connector's message_to_item and ingest_items functions from your handler. The agent can then recall a message seconds after it lands.

If you run many agents or customers from one HydraDB database, set HYDRADB_COLLECTION to give each one its own sub-tenant scope.

The full reference lives in our HydraDB integration docs, and the connector source is on GitHub.

FAQ

Questions, answered.

HydraDB is a context and memory layer for AI agents, built as an open-source graph database on object storage. It stores memories and knowledge from app sources so agents can retrieve the right context at query time. You can self-host it or use HydraDB Cloud.

The hydradb-agentmail-plugin connector syncs messages from an AgentMail inbox into a HydraDB database as an app source. Each message keeps links to its thread and to the message it replied to. Your agent queries HydraDB before replying and gets back relevant past email with its conversation context.

Both. Run agentmail-sync with no arguments to sync every inbox on the account, or pass an inbox address such as agentmail-sync agent@agentmail.to to sync just that one.

Yes. Subscribe to the message.received and message.sent webhook events in AgentMail and call the connector's message_to_item and ingest_items functions from your webhook handler. Each email is ingested as it arrives. You can also run the sync on a schedule for backfill.

No. The connector uses each email's RFC Message-ID as its upsert key, so a re-sync updates existing messages instead of adding copies. Set AGENTMAIL_AFTER to an ISO 8601 timestamp to pull only newer mail.

No. The integration connects inboxes you already have to HydraDB. You need an AgentMail API key, a HydraDB API key and database, and Python 3.9 or later.

Blog

Suggested reading

View all posts

News · November 4, 2026

Introducing Polling Webhooks

Polling webhooks let an AI agent fetch its email events from a queue whenever it runs, with no public URL or open connection. Built in partnership with Svix.

Prompt

Give yourself access to AgentMail by following the guide at:

https://docs.agentmail.to/agent-onboarding.md

and refer to:

https://docs.agentmail.to/llms.txt

for the documentation index.

Start integrating AgentMail into your AI agents today.