How do I manage threaded conversations?
Maintain context across multi-turn email conversations with your agent.
Maintain context across multi-turn email conversations with your agent.
Threads are how AgentMail organizes conversations. Every time your agent sends a new email, a thread is created. Replies are automatically grouped into the same thread, giving your agent full conversation context.
You never need to create threads manually. AgentMail handles threading automatically using standard email headers (Message-ID, In-Reply-To, References).
This org-wide query is useful for building supervisor agents that monitor conversations across a fleet of other agents, analytics dashboards, or routing systems that escalate conversations between agents.
Retrieve a thread by its ID to access all messages in the conversation:
To continue a conversation, reply to the most recent message in the thread:
Always provide both text and html when sending replies. This ensures readability across all email clients and improves deliverability.
When people reply to emails, their email client often includes the entire previous conversation as quoted text. AgentMail provides extracted_text and extracted_html fields on received messages, which contain only the new reply content without the quoted history.
This prevents your agent from re-processing the entire conversation history on every reply.
Combine threads with labels to manage your agent’s workflow. For example, you can track which threads need a reply:
client.threads.list() to build dashboards or route conversations between agentsunreplied, replied, escalated, and resolved to track conversation state