Returns the messages to send so they fit in budgetTokens, with the
system prompt counted:
Under budget: the same array.
Else, from the oldest, tool results are cut to one short line.
Still over: the oldest whole turns are dropped, and a note goes first.
The last 4 user turns (a user message and everything after it until the
next one) are never touched. Whole turns are dropped, so a tool call is
never split from its result.
Returns the messages to send so they fit in
budgetTokens, with the system prompt counted:The last 4 user turns (a user message and everything after it until the next one) are never touched. Whole turns are dropped, so a tool call is never split from its result.