ConversationSegmenter

constructor(maxSize: Int = DEFAULT_MAX_SIZE, settle: Duration = DEFAULT_SETTLE, minItems: Int = 1)

Parameters

maxSize

ceiling on a single segment, expressed in whatever units the size accessor passed to closedSegments returns. Under the default accessor (one unit per item) it is a message count; a caller supplying a token estimator must scale this accordingly. A segment absorbing an undersized tail (see minItems) may exceed it by up to minItems - 1 items: maxSize is a coherence cap, not a hard limit.

settle

how long a conversation must be quiet before it is taken to be finished: the trailing segment becomes extractable, and any later item starts a new segment.

minItems

segments holding fewer items than this are dropped. Cuts are placed so that no segment falls below the floor, and an undersized tail is folded back into the segment before it, so only a whole conversation shorter than minItems is dropped. Setting minItems above the number of items maxSize admits leaves every segment below the floor, discarding the stream entirely.