• Precompute Document token count before sub-batching them as List<List<Document>>.
  • Configurable threshold value for the upper bound of max input tokens.

Resolves https://github.com/spring-projects/spring-ai/issues/1260

Comment From: markpollack

merged in 73d0b301d6a5c25de8a515c2316a97f68cbbed8f

renamed 'thresholdFactor' to 'reservePercentage' for clarity and refactored the formula to use (1 - reservePercentage) for clarity