AgentMailRetriever performs a keyword search over an AgentMail inbox. It loads recent messages via AgentMailLoader, scores them in-process with a case-insensitive substring match (subject hits weighted 2×), and returns the top-k as LangChain Documents. For semantic search, pair AgentMailLoader with your own vector store instead.
Overview
| Class | Package |
|---|---|
AgentMailRetriever | langchain-agentmail |
Setup
Install the package:Instantiation
Usage
Document shape as AgentMailLoader — full plain-text body in page_content, plus inbox/message/thread/sender metadata.
When to use the loader instead
AgentMailRetriever is the “just give me recent messages matching X” escape hatch — no embeddings, no vector store. If you need semantic retrieval, ranking by relevance, or filtering across millions of messages, use AgentMailLoader to materialize Documents and feed them into a real vector store. See the document loader page for that flow.
API reference
The package source lives at github.com/agentmail-to/langchain-agentmail.Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

