Skip to content

Truncation and lost instructions

What it looks like

The app worked fine in testing. Then a user pastes a long document, or a chat runs for an hour, and the model starts ignoring rules it followed earlier. It forgets the output format. It answers in the wrong language. Or the reply simply stops in the middle of a sentence.

Why it happens

Every model has a context window: a hard limit on how many tokens it can handle in one request. Your system prompt, the chat history, retrieved documents, tool results and the reply all share that space.

When the total gets too big, something has to give. Depending on your stack, the API may reject the request, your framework may drop old messages, or your own code may slice the text. If the slicing starts from the top, the first thing lost is often the system prompt or the first user instruction. Those are usually the parts that matter most.

A reply that stops mid-sentence is a different limit: the output cap. The model hit the max output tokens you set (or the default) and stopped.

How to spot it

Fix checklist

  1. Count tokens before each call and log the total next to the model's limit.
  2. Treat a length stop as an error, not a normal answer. Retry with a smaller input or a higher output cap.
  3. Trim or summarize old turns yourself, so you choose what goes. Never let the oldest message be the system prompt.
  4. Keep core instructions short, and repeat the most important one near the end of the prompt.
  5. Test with a deliberately long input before you ship.

Lasting fix

  • Coding with AI? COSMOS CODE (in development): let AI write code without letting it wreck your repo.

Related on Solaro sites

  • ModelRaters : see the “Best for long documents” list before you pick a model for long input.
  • DailyScar : read the story “Eaten at the Letter G” (on the DailyScar front page).

Will it fit? Check your prompt against the model’s context window in the Context planner

Next

Read Count tokens before you send for a small check you can paste into your code, then Long-chat drift.

All failure modes