Class TurnCountTrigger

java.lang.Object
org.springframework.ai.session.compaction.TurnCountTrigger
All Implemented Interfaces:
CompactionTrigger

public final class TurnCountTrigger extends Object implements CompactionTrigger
Fires when the view holds more than a number of turns: a user message and everything up to the next one. Counting turns rather than events follows the shape of the conversation, and never fires in the middle of a tool-calling exchange. Pair it with a turn window, so the threshold and the window count the same thing.
Since:
2.1.0
Author:
Christian Tzolov
See Also:
  • Constructor Details

    • TurnCountTrigger

      public TurnCountTrigger(int maxTurns)
      Parameters:
      maxTurns - the number of turns the view may hold before compaction; positive
  • Method Details