Skip to main content

Real architecture · Senior

Shortwave: email assistant with RAG

Real production architecture. Key points: tool selection, query rewriting, and context budget.

17 min read · Source: Shortwave · Content reviewed on October 23, 2026

Short answer

Real production architecture. Key points: tool selection, query rewriting, and context budget. Shortwave, an email app, built an AI assistant with retrieval-augmented generation (RAG). Each user's inbox gathers correspondence, calendar invites, receipts, notifications, and newsletters. The company wanted a knowledge base built from it, but earlier attempts with traditional search had been disappointing, and LLMs could change that.

01 · CONTEXT

An email assistant with RAG

Shortwave, an email app, built an AI assistant with retrieval-augmented generation (RAG). Each user's inbox gathers correspondence, calendar invites, receipts, notifications, and newsletters. The company wanted a knowledge base built from it, but earlier attempts with traditional search had been disappointing, and LLMs could change that.

For users, the company describes the AI as a person sitting next to them, with perfect knowledge of their email history. This simple mental model helps predict what the assistant can do and how to use it better.

02 · ARCHITECTURE

One large prompt, four steps

The central principle is that how to answer a question should be handled by the LLM itself; the system's job is to find the right data. According to the team, long chains of LLM calls introduced data loss and errors at each stage, with low-quality answers. Instead, the answer comes from a single LLM that receives all the context in one large prompt, which depends on a very capable model and a large context window.

To organize this, Shortwave created the Tool abstraction. Each type of data, such as calendar, email history, or draft, comes from a different tool, and each tool decides internally which specific data goes into the final prompt.

When answering, the assistant follows four steps: tool selection, retrieval of the tools' data, answering the question, and post-processing.

  1. The user's question goes immediately to an LLM. This call is not for answering, but for determining the types of data that need to be gathered.

    Architecture diagram: Shortwave assistant: the four steps
    CLEmail app
    CPTool selection (LLM)
    CPData tools
    CPFerramenta EmailHistory (AI Search)
    CPAnswer (LLM)
    CPPost-processing
  2. The selection can return no tools, one, or several, and the prompt for this step carries details such as the app's current state.

    Architecture diagram: Shortwave assistant: the four steps
    CLEmail app
    CPTool selection (LLM)
    CPData tools
    CPFerramenta EmailHistory (AI Search)
    CPAnswer (LLM)
    CPPost-processing
  3. The chosen tools retrieve their data in parallel. The most complex is EmailHistory, which gives the assistant knowledge of the entire email history.

    Architecture diagram: Shortwave assistant: the four steps
    CLEmail app
    CPTool selection (LLM)
    CPData tools
    CPFerramenta EmailHistory (AI Search)
    CPAnswer (LLM)
    CPPost-processing
  4. With the data gathered, the system builds a prompt with the original question and the context brought by the tools and hands it to an LLM.

    Architecture diagram: Shortwave assistant: the four steps
    CLEmail app
    CPTool selection (LLM)
    CPData tools
    CPFerramenta EmailHistory (AI Search)
    CPAnswer (LLM)
    CPPost-processing
  5. Here you need to decide how to allocate tokens among the tools, because EmailHistory usually produces far more content than fits in the prompt.

    Architecture diagram: Shortwave assistant: the four steps
    CLEmail app
    CPTool selection (LLM)
    CPData tools
    CPFerramenta EmailHistory (AI Search)
    CPAnswer (LLM)
    CPPost-processing
  6. Finally, post-processing converts the output into rich text, adds source citations, and suggests actions to the user.

    Architecture diagram: Shortwave assistant: the four steps
    CLEmail app
    CPTool selection (LLM)
    CPData tools
    CPFerramenta EmailHistory (AI Search)
    CPAnswer (LLM)
    CPPost-processing

03 · CONTEXT BUDGET

More data than fits in the prompt

AI Search looks for relevant emails across the user's entire history and orders them by usefulness, so that smart trade-offs can be made when answering. The results often reach a thousand or more, and they must be cut down to a few dozen, and fast.

In the answer step, this becomes a context budget question: you must decide how to allocate tokens among the tools, because EmailHistory usually produces far more content than fits in the prompt. The post mentions heuristics for making these trade-offs.

05 · TRADE-OFFS

Two re-ranking phases and the total cost

AspectoHeuristics phaseCross-encoder phase
RoleUses fast heuristics to cut the large listScores each fragment by its relevance to the question
EntradaRetrieved emails, ordered by semantic similarityReformulated query and pre-selected fragments
CharacteristicLocal heuristics based on the extracted featuresModel smarter than the heuristics, but slow, on in-house GPUs

The team optimized the system to answer almost all questions in 3-5 seconds, and this end-to-end latency includes several LLM calls, ElasticSearch queries, and calls to open models. The system uses concurrency, streaming, and pipelining and a lot of computing power: robust servers and clusters of top-end GPUs.

Frequently asked questions

What is Shortwave: email assistant with RAG?

Real production architecture. Key points: tool selection, query rewriting, and context budget.

What does the Shortwave: email assistant with RAG design cover?

It is organized in these sections: An email assistant with RAG, One large prompt, four steps, More data than fits in the prompt, From the question to the email ranking, and Two re-ranking phases and the total cost.

How long is Shortwave: email assistant with RAG and what level is it?

It takes about 17 minutes to read and is rated Senior level.

Now design it yourself

Run this case as an interview in the System Design school: you make the decisions, the tutor challenges them and you see how your design scores.