package vip.mate.llm.cache; import org.springframework.ai.chat.messages.Message; import org.springframework.ai.chat.messages.MessageType; import org.springframework.ai.chat.prompt.Prompt; import vip.mate.llm.model.ModelProtocol; import java.util.List; /** * 策略评估缓存方案时所需的只读上下文。 * *
不持有 {@link Prompt} 引用以外的可变状态;所有派生指标(system 长度、tool 数等)按需懒计算 * 并由 record 字段缓存,避免重复扫描。
*/ public record CachePlanContext( Prompt prompt, ModelProtocol protocol, int totalPromptTokens, int turnCount, int minPromptTokens, int maxBreakpoints, boolean includeToolsBlock, CacheTtl ttl) { public CachePlanContext { if (prompt == null) throw new IllegalArgumentException("prompt must not be null"); if (protocol == null) throw new IllegalArgumentException("protocol must not be null"); if (ttl == null) ttl = CacheTtl.DEFAULT_5M; if (maxBreakpoints <= 0) maxBreakpoints = 4; } /** 消息列表(不可变视图;上层不应修改)。 */ public List