Every chat product hits this on day two. The conversation grows, the window does not, and something has to go. Drop the wrong thing and the assistant forgets its instructions or the API rejects the request outright.
Write fit_history(messages, max_tokens).
messages is a list of {"role": ..., "text": ...} in chronological order, where role is "system", "user" or "assistant". A message costs len(text.split()) tokens. Return the messages to send, still in chronological order:
You have read the opening. The rest is free with a Bezen account, and no card is needed.
Behind the sign-in