BT San Technology

15 July 2026

Tokens and Context Windows: Why an AI Forgets in a Long Chat

5 min read · AI for business · AI basics

Illustration: a long tray filled with tiles, a few tiles left outside because they don't fit, a long document behind
AI-generated illustration

You send an AI a contract PDF of dozens of pages and ask for a summary. After several more rounds of chat, it answers as if it forgot what you asked at the start, or the system says the message is too long. The cause is usually tokens and the context window, which are worth understanding before you set up an AI system for real work.

What is a token?

A token is a small unit of text that the model uses to read and write. It can be a single character, a whole word, or part of a long word, as Google's documentation explains. Splitting text into tokens is called tokenization.

Some providers' documentation gives estimates for English, but those figures are not fixed numbers for Thai. Thai may be counted into a different number of tokens than English. To know the real number, use the provider's token-counting tool on your own text.

What is a context window?

The context window is the model's working space for one request. Think of a desk that can only hold so much: everything the model needs must be on the desk at the same time. Anthropic's documentation explains that this space includes both what you send in and the answer the model writes out.

  • The system prompt that sets the role and rules
  • The earlier chat history
  • Documents or search results you attach
  • The current question
  • The answer the model is going to write

If the total goes over the limit of the model you use, the system may return an error, or a chat app may quietly cut off the oldest messages. The result is that the AI seems to forget, when in fact that text has fallen off the desk.

Hypothetical example: suppose a model has a context window of 10,000 tokens. The system prompt uses 800, the chat history 3,200, the attached document 4,500, and 1,000 is reserved for the answer. That totals 9,500, leaving 500 tokens free. If the user attaches another 1,000 tokens of documents, the total goes over the limit, and the system has to cut something out or return an error. These numbers are made up to show the addition. They are not the limit of any model.

Fitting more in does not mean better answers

A model that accepts very long text does not necessarily recall every part equally well. Anthropic's documentation warns that as the context gets longer, accuracy in recalling information may drop. So stuffing everything in is not always the answer. Pick only the relevant parts.

  • Split documents into chunks and send only the chunks relevant to the question (the same idea as RAG).
  • Summarize the chat history into a few short points, and start a new chat when the topic changes.
  • Keep fixed information, such as company policy, in a concise system prompt.
  • Set a cap on answer length that suits the task.

Counting tokens and planning

Many providers have a tool that counts tokens before you send a request, for example from Anthropic and Google, and it counts the system prompt and tools as well. Anthropic's documentation says the counted number is an estimate that may differ slightly from the real number.

Also note that different models may count the same text differently, because they use different tokenizers. Anthropic's documentation recommends recounting with the model you will actually use, not reusing numbers from an older model. The limit for each model can change, so check the provider's documentation when you design the system.

Checklist before you build

  • Collect samples of the longest document and the longest conversation you expect.
  • Count the tokens of those samples with the tool for the model you will use.
  • Decide whether to send the whole document or only the relevant chunks.
  • Agree on what happens when the text is too long: tell the user, or summarize automatically.
  • Test that a question at the end of a conversation can still refer correctly to something from the start.

The limits are these: this article gives no limit figure for any model, and Thai token counts must be measured on real text. Another option for large document sets is to search the documents before answering. That reduces the load on the desk, but a person still needs to check important answers.

Talk to BT San

If your work involves long documents, such as contracts, production reports or maintenance records, prepare a sample of the longest one and the questions you want to ask. Then talk to the BT San team about how to split the documents and check the answers so they fit your work.

References

  1. Claude API docs: Context windows (accessed 2026-11-20)
  2. Google Gemini API docs: Understand and count tokens (accessed 2026-11-20)
  3. Claude API docs: Token counting (accessed 2026-11-20)

Add us on LINE

Scan with the LINE app on your phone

QR code to add LINE @Bankoos

LINE ID: @Bankoos

Open LINE on this computer