Token阈值事件压实机

An EventCompactor that compacts events once the most recent prompt reaches a token threshold, keeping a tail of recent events raw (tail retention).

It is intended to run intra-invocation, before each model call: when the most recently observed prompt token count reaches tokenThreshold, every event older than the last eventRetentionSize events (since the previous compaction) is summarized into a single event, while the most recent events are preserved raw to maintain continuity.

“安全网”(Safety net)是一个比喻性术语,用来形容那些在关键时刻能够提供帮助或支持的系统或机制。例如: 1. **经济保障**:政府提供的失业救济金或养老金,可以在人们失业或年老时提供经济支持,从而避免陷入贫困。 2. **医疗体系**:当人们生病时,医疗保险可以支付医疗费用,确保他们能够得到必要的治疗。 3. **教育资源**:政府或非政府组织提供的免费或低成本的教育机会,可以帮助贫困家庭的孩子获得教育。 4. **紧急救援系统**:在自然灾害或突发事件发生时,救援机构能够迅速提供援助,减轻人们的损失。 这个术语强调的是在面临风险或困难时,某种机制或资源能够起到缓冲作用,保护人们免受最严重的后果。

The window never strands an open interaction: the window is shrunk to its longestSelfContainedPrefix. A summarizer failure skips the compaction instead of failing the caller, since the uncompacted history is still usable.

Parameters

config

The compaction configuration; must have token-threshold fields set.

agentName

The current agent name, used when estimating the prompt token count.

branch

The current invocation branch, used when estimating the prompt token count.

构造函数(Constructors)

Link copied to clipboard
constructor(config: EventsCompactionConfig, agentName: String, branch: String?)

函数

Link copied to clipboard
open suspend override fun compact(session: Session, sessionService: SessionService)

压缩给定会话中的事件。如果发生了压缩操作,新的压缩事件将会被添加到该会话的记录中。 sessionService.