What does "context length exceeded" or "message too long" mean?
It means the text you sent, plus any reply space reserved for the answer, is larger than the model can handle in one request. You must send less, split the work or summarize.
Fixes:
- Split a long document into sections and process each separately.
- Summarize earlier chat turns and start fresh with the summary.
- Remove attachments or pasted text you do not need.
- In the API, lower the maximum output setting. Input plus output has to fit together.
- Count tokens before sending with a tokenizer tool from the vendor.
- For big document sets, use retrieval (RAG) so only relevant passages are sent.
Why it happens: every model has a context window measured in tokens, and the window covers your prompt, history, attachments and the answer. Window sizes differ by model and change often, so check the vendor's current model documentation instead of relying on numbers you read elsewhere.
Related answers
Are AI-written phishing emails harder to spot, and what should I look for now?
Yes, AI can write clean, convincing phishing emails without the spelling mistakes people used to rely on, so judge the request and the sender, not the grammar.
privacy-safety
Can AI analyze my Excel or CSV data and can I trust the results?
Often yes, especially with assistants that can run code on uploaded files, but you should verify the results.
accuracy
Can an AI assistant be tricked by hidden instructions in emails or web pages?
Yes. If an assistant reads emails, web pages or documents, hidden text in them can try to give it new instructions, which is called prompt injection.
privacy-safety