Email threading for AI agents
How does an AI agent keep an email conversation in one thread, and what happens when a person steps in?
The short answer
An agent keeps a conversation in one thread by answering with the right headers: In-Reply-To set to the Message-ID of the message it answers, and References carrying the chain before it. With Zurchin the agent names the message it answers and Zurchin sets the headers. Incoming mail is threaded on arrival by the same headers, and each thread records whether the agent or a person is answering it.
How email knows what belongs together
Every email carries a Message-ID, a unique string its sender's server stamps on it. A reply names its parent in In-Reply-To and lists the conversation so far in References. Mail clients read those two headers to draw a thread. When they are missing, most fall back to the subject, stripped of Re: and Fwd:.
An agent that writes its own MIME, or calls a send API with a subject of Re: Your order and no headers, breaks this. In its own records the reply may look threaded. In the customer's client it can arrive as a new conversation, beside the one it answers, and the customer has two places to reply.
There is a second trap. Some sending services replace the Message-ID you set with one of their own. Amazon SES, which Zurchin sends through, does: the recipient sees an id ending in amazonses.com, not the one stored at send time. A reply that quotes the stored id names a message the recipient never received. Zurchin puts the id the recipient actually saw into In-Reply-To and References when it answers its own sent mail, and matches incoming replies against both.
How Zurchin threads incoming mail
A thread has an id, and every message and event names it. When mail arrives:
- The headers decide.
In-Reply-ToandReferencesare matched against messages at the same address. A match puts the message in that thread. - Otherwise a new thread. Zurchin does not guess from the subject, so two unrelated "Invoice" emails stay two threads.
Either way, message.received names the thread the message joined.
A message your agent composes from scratch always starts a thread of its own. Five identical requests to five suppliers are five conversations, not one with five people in it.
Replying over the API
A send names the message it answers in reply_to, and Zurchin files the reply in that thread and sets In-Reply-To and References for it; the agent brings the recipients, the subject and the text. Over MCP, reply_to_message takes the rest off the message too: it answers the sender (or, for mail the inbox sent, its recipients) from the same inbox, with Re: before the subject.
To read the conversation before answering, the agent reads the thread's messages. Give the model only the new words of each message, with the quoted history cut off, and it reads the conversation once, not once per quote. Do not cut a forward, because what it carries is the point.
Over MCP the same steps are one tool to read the thread and one to reply.
Who is answering
Threading tells you which messages belong together. An agent in a real inbox also needs to know whether it is still the one answering. Each Zurchin thread records who owns it, agent, human or automation, and where it stands: open, waiting, resolved or human_review.
Mail arriving at an inbox opens a thread the agent owns. When the agent is out of its depth, it hands the thread over in one call, with owner_type: human and status: human_review, and can name the member who should take it with assignee_id.
That member, or everyone on the team when nobody is named, gets an email with the latest message. While a person owns the thread, new mail in it reaches them the same way, at most once every fifteen minutes. The customer keeps writing to the same address and sees nothing change.
A person answering
The person can answer from any mail app connected to the agent's address over IMAP and SMTP, with an app password for that inbox. Their reply names the message it answers, so it joins the same conversation and, for the customer, is the next message in it.
Zurchin does not stop an agent from sending in a thread a person owns; that rule is yours to keep. Your agent learns of every hand-over from thread.updated, in the events it already reads. Check who owns the thread when a message arrives, before answering, and leave a thread whose owner is human alone until it is handed back, with the same call and owner_type: agent.
Limits
- Threads are per address. The same conversation copied to two of your addresses is two threads, one in each inbox.
- No headers, no thread. A sender whose client drops
In-Reply-ToandReferencesstarts a new thread, even with the same subject. - Zurchin ships no agent loop. Threads, owners and events are what you build one on; the model, the prompt and the decision to answer are yours.
Start
Sign up and create an inbox for your agent. The human-in-the-loop post has the reasoning behind the hand-off.
Everything an agent's inbox does is on Zurchin Email.
Questions
Which headers keep a reply in the same thread?
In-Reply-To, set to the Message-ID of the message being answered, and References, carrying the chain before it. Most mail clients fall back to the subject only when those are missing.
How does an agent reply in the same thread with Zurchin?
It names the message it answers, and Zurchin sets the threading headers. Over MCP, reply_to_message also takes the recipient and subject from that message; the agent brings the text.
How does Zurchin decide which thread incoming mail joins?
By the In-Reply-To and References headers, matched within the address. A message that names none starts a new thread.
What happens when the agent hands a thread to a person?
The thread's owner becomes human, the named member or the whole team gets an email, and a thread.updated event says so. The agent should leave the thread alone until it is handed back.