/// Begins a part which carries on with a message the part before ended with.
/// </summary>
internalconststringCONTINUATION_MARKER="[... continuation of the message the previous part ended with ...]\n";
/// <summary>
/// Ends a part whose last message continues in the next part.
/// </summary>
internalconststringTO_BE_CONTINUED_MARKER="\n[... the message continues in the next part ...]";
/// <summary>
/// How much of a text fits, measured against what the estimate says would fit exactly.
/// </summary>
/// <remarks>
/// The tokens of a piece of a text are only estimated from its characters, and a few tokens go to
/// the markers, so splitting leaves some room.
/// </remarks>
privateconstdoubleCUT_MARGIN=0.9;
/// <summary>
/// Renders one message for the AI which writes the summary.
/// </summary>
/// <remarks>
/// A heading names the number, the author, and the time, so that the summary can keep the order
/// and tell who said what. Messages hidden from the user, such as the prompts an assistant sent
/// into the chat, are marked: the user never saw them, which matters for how the summary words
/// them. So are the messages of the last exchange, which the summary must neither summarize nor
/// repeat. The time is the stored one, in invariant notation, so that a summary does not depend
/// on the language of the app.
/// </remarks>
/// <param name="block">The block of the message. It must be one which the message builder sends, see ChatCompressionPlan.</param>
/// <param name="number">The number of the message in the conversation, counted from 1.</param>
/// <param name="text">The text of the message: the one the AI received in the chat, with the content of its documents, or the bare text of a message of the last exchange.</param>
/// <param name="kept">Whether the message follows the summary word for word.</param>
/// <returns>The message as the AI reads it.</returns>
/// Takes the next part of the messages, as many as fit into the given number of tokens.
/// </summary>
/// <remarks>
/// The summary asks for one part at a time, because the room for a part shrinks as the summary
/// so far grows, which only shows after each answer.<br/><br/>
///
/// Messages stay whole and in their order where they can. A message which does not fit into
/// what is left of the part starts the next one. A message larger than a whole part is split:
/// the part takes as much of it as fits, preferably up to the end of a line, and the next part
/// carries on where it ended. Markers tell the AI where a message breaks off and goes on. A split
/// never falls between the two halves of a surrogate pair.
/// </remarks>
/// <param name="messages">The rendered messages with their tokens, in the order of the conversation.</param>
/// <param name="start">Where the part begins: its first message, and the offset in its text, which is 0 unless the part before split the message.</param>
/// <param name="tokensPerPart">How many tokens of messages the part may hold.</param>
/// <returns>The text of the part, and where the next part begins.</returns>