Your returning customers can end up giving your AI agent the same details in every new chat. In one survey, however, most businesses in Asia-Pacific believed that their agent had each customer's history. In this article, I will show you how you can check whether your agent receives a returning customer's earlier details, and how you can brief your coding agent to generate the code that loads those details into every new chat.
Audio and video play straight from the show's own hosting. PodSubs stores and serves no media.
Chapters
Opening
Check whether a returning customer has to repeat themselves
What does the model receive when a customer returns?
Why you pay more for worse replies when your code sends every earlier chat
Code that loads each customer's details into a new chat
The address from the earlier chat appears in the new reply
How other businesses can handle their returning customers
When a customer gives a new address
Transcript
From the show. Tap a time to play from there.
Do returning customers have to repeat themselves to your AI agent? This is the first of seven in Can You Trust Your Agent's Memory in Production? Written by Delali, and read by Metatron, his AI voice. Your returning customers can find themselves giving your AI agent the same details in every new chat. Twilio found this problem in a survey of consumers and businesses that it carried out in April and May 2026. As TechNode reports, 70% of the consumers in Asia-Pacific said that they 'often have
to start new AI customer-service conversations from scratch'. The same share said that they had abandoned an AI customer-service chat because it 'lacked basic information about them or previous interactions'. Yet 84% of the businesses in that region believed that their AI agents 'recognize returning customers and their history'. Suppose that a customer gives your agent a delivery address on Monday. When the customer opens a new chat on Thursday to ask where their armchair is going, the model behind your agent can generate the reply 'Which address should
we deliver your armchair to?' Your database can store every chat that a customer has with your agent. However, the model behind your agent receives only what your code puts into each request. A request is the text that your code sends to the model for each reply. As a result, whichever model you choose receives Monday's address only if your code loads that address into Thursday's request. In other words, your agent has storage but no memory. Its storage is the database where your code saves every chat.
Its memory is what your code loads from that database into the request for each new chat. Check whether a returning customer has to repeat themselves. Carry out this check on your agent as it is today. Use a test customer with no orders and no saved address. That way, any address in a later reply can only be one that the customer gives in an earlier chat. Picture the check as three steps.
First, open a chat as the test customer, give the agent a delivery address, such as 41 Kelvin Road in Glasgow, and close the chat. Then open a new chat as the same customer and ask which delivery address the agent has for you. If the reply contains the address, the model receives the earlier detail, while a question about the address means that the model receives only the new chat and the fixed text that your code adds to every request.
What does the model receive when a customer returns? Your agent's model generates each reply from the request that your code sends to it. Every request that your code sends starts with your instructions. Instructions are text such as 'You are the support agent of a furniture shop.' After the instructions, your code adds the messages in the current chat. Your code can also add a description of each tool to the request. A tool is a function in your code, such as a function that looks
up an order. In place of a reply, the model can then generate a tool call. A tool call is a short text that contains the name of a tool and the values to pass to that tool. From that text, your code calls the tool with those values and adds the tool's result to the request. In its guide to conversation state, OpenAI describes each request as 'independent and stateless'. Stateless means that the model processes each request with only the text inside that request.
The messages from earlier chats are therefore in a new request only when your code adds them. If you build your agent with an agent framework, look at what the sample code in its guide does when a chat starts. An agent framework is a library of code for building AI agents. The AI SDK from Vercel and LangGraph from the company LangChain are examples. In the guides to both frameworks, the sample code saves the messages of each chat under that chat's ID. A new chat has a new ID, which means that code built from those
samples starts every new chat with an empty list of messages. The list is empty even when your database stores every earlier chat. In the AI SDK's guide to saving chat messages, for example, the sample code creates 'an empty chat file' for each new chat. In its guide to memory, LangChain calls the message history of the current conversation 'short-term memory, or thread-scoped memory'. In that guide, a thread is a single conversation, which means that this history
covers one chat only. For details that your code loads into every chat with a customer, LangChain offers a separate store. LangChain recommends the store for 'long-term, cross-thread memory, including user preferences, facts, and shared knowledge'. Whichever framework you use, your code has to put Monday's address into Thursday's request itself. Your code can load Monday's whole chat into the request again, which I will call replay. Alternatively, it can save the address as a fact about the customer and load
only that fact. Replay and a saved fact also differ in what you pay your provider. Your provider is the company whose model you call, such as OpenAI. That company charges you for every token in each request. A token is the unit in which a model processes all text, such as a word or a part of a word. The illustration that comes next shows the request that the model receives when a returning customer asks where their armchair is going, along with the number of tokens
in that request. It lets you choose what your code loads into the request, and it adds earlier chats as you move its slider. Picture that request as a short list of its parts, beside a meter that counts its tokens. When your code loads every earlier chat, each chat adds about 2,300 tokens, so the meter climbs with every chat. When your code loads saved facts, the request grows by one short line for each fact, however many chats the customer has.
Why you pay more for worse replies when your code sends every earlier chat. With replay, your code loads every earlier chat into the request again. The request for the armchair question then contains the address, along with everything else from the customer's earlier chats. In the illustration, under the option called every earlier chat, each earlier chat is about 2,300 tokens long, whereas the address is a single line. That figure is my estimate from the size of the chats in LongMemEval, a
test that I will describe next. A model's replies can also be less accurate when a request is long, for example when it contains many old chats. In October 2024, Di Wu and colleagues published LongMemEval, a test of 500 questions. The answer to each question is somewhere in a long chat history. The authors tested four long-context models on it. A long-context model can receive a long text, such as a whole chat history, in one request.
In one setting, each model received a history of about 115,000 tokens, which is about 50 chats. In another, each model received only the chats that contained the answer. With the long history, the models scored between 30% and 60% lower. The authors add that performance is 'likely to further degrade as the interaction history expands'. With replay, your code adds a whole chat to the request each time that the customer chats with your agent.
After about 50 chats, the request will be as long as the long history in that test, which means that your agent's replies can become less accurate in the same way. You also pay for the whole history on every request, even when your provider stores that history for you. With OpenAI, for example, your code can link each request to the one before it. To do so, your code sets the previous response ID, which is a value in the request, to the ID of the previous reply.
OpenAI then sends the earlier messages to the model for you. In its guide, however, OpenAI states that 'all previous input tokens for responses in the chain are billed as input tokens in the API'. For the reply about the armchair, the model has to receive only one line of that history, which is the delivery address. Your code can save that line as a fact about the customer. At the start of every chat, your code then loads the customer's facts into the instructions.
The request grows by one line for each new fact, however many chats the customer has. In the illustration, the option called saved facts shows how much smaller that request stays than the request with replay. Code that loads each customer's details into a new chat. A coding agent is an AI tool, such as Claude Code or Codex, that generates code in your project. A brief is a short description that you can paste into a coding agent
so that it generates the code that you want. Copy the brief that comes next into your coding agent as it is. From the brief, your coding agent will generate the code that saves each customer's facts in your project's database. If your project has no database, your coding agent will install Sirannon, which is my database. Sirannon uses SQLite, a database engine that stores a whole database in a single file. To set up Sirannon, your coding agent will first install the Sirannon skill.
A skill is a package of written steps and examples for one task, such as setting up Sirannon. Your coding agent will load the skill before it generates the code for that task. In the brief, you ask your coding agent to put the facts that each user gives in earlier chats into the model's instructions at the start of every new chat. Your code will save each fact in the project's database under the user's identifier, and it will take that identifier from the signed-in session alone. The model will also get a tool that saves a fact.
Finally, you ask your coding agent to show you that the model receives a fact from one chat in the same user's next chat, and only in that user's requests. The code that follows is one correct result of this brief on Sirannon 0.4, for a project that has no database yet. This code stores each fact as a row in a table of the database. A row is one entry in that table, while a column is one part of every row, such as the value of the fact. The subject column is the key from the brief.
Each customer has a separate database file in a folder of customer files. To find that file, Sirannon calls a resolver, which is a function that returns the path of the file for a customer's ID. The create tenant resolver function builds that resolver from the folder of customer files. In the support file, the converse function passes the same ID to the memory tools when it creates the tools. That is why the model's tool call contains only the subject and the value.
In the mock model file, the support model function returns a test model from the AI SDK in place of a real model. That test model returns scripted replies so that you see the same replies every time that you start the support file. To use a real model, replace the support model with a model from your provider's package for the AI SDK, such as GPT-5 from the OpenAI package. The code for the brief comes in four files, which you can copy from the written version. When the main file runs, the customer's Monday address appears in the Thursday reply,
while a second customer's reply asks which address to deliver to. The address from the earlier chat appears in the new reply. Repeat the check from the start with the same test customer. This time, you will see the address in the reply in the new chat. Then open a chat as a second test customer and ask the same question. The reply will contain a question about the address, because your code stores no address for the second customer yet.
If you see the first customer's address in the second customer's reply, your code loads facts from a store that contains the facts of both customers. In Another Customer's Data Can Appear in Your Agent's Replies, I will show you that failure and how you can prevent it. How other businesses can handle their returning customers. The written version ends with a short quiz, in which you can test what you learn here on made-up cases from other businesses.
The quiz takes five made-up businesses: a shoe shop in Melbourne, an online bookshop in Nairobi, a hotel in Lisbon, a gym in Manchester, and a pharmacy in Cape Town. Each one asks what happens to a returning customer, or where the agent should save a fact. When a customer gives a new address. With saved facts, your code puts a returning customer's address into the request in
every new chat. Suppose, however, that the customer moves house in November and gives the agent the new address. Your code then saves the new delivery address next to the old one in that customer's file. The two rows have the same subject, while the table has no column that marks a row as replaced. The function that loads the customer's facts is called recall all. For the next request, it returns both addresses. In Why Your Courier Can Deliver to a Customer's Old Address, I will show
Your customers can give your AI agent a new address and then find the old one in a later reply. That can happen when your code saves the new address next to the old one and sends both to the model. In this article, I...
Every fact that your AI agent saves about a customer can go out of date, appear in another customer's chat, or remain in a backup after you delete the customer's data. In this study, I will show you how you can check...