To summarise a document far bigger than the context window: summarise groups of chunks (map), then summarise the summaries (reduce), repeating until one call can see everything.
Implement plan(chunk_tokens, context_limit, summary_tokens, overhead):
overhead (instructions), and must fit in context_limit.ValueError.summary_tokens tokens.summary_tokens is so large that a level doesn't shrink the number of items, raise ValueError (it would never finish).Return a list of levels, each a list of group sizes (items per call). Also implement total_calls(levels).