Builder
public static class Builder
io/agentscope/harness/agent/memory/compaction/CompactionConfig.java:271–402构建器,用于构建并配置目标实例。位于 io.agentscope.harness.agent.memory.compaction 包。核心成员包括 triggerMessages、triggerTokens、reserved、keepMessages、keepTokens、keepTokensMin。
A class in io.agentscope.harness.agent.memory.compaction that persists and restores session and memory data across calls. Declared in io.agentscope.harness.agent.memory.compaction.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Builder triggerMessages(int triggerMessages) | 设置该配置项。 Trigger compaction when conversation has at least this many messages (0 = disabled). |
public Builder triggerTokens(int triggerTokens) | 设置该配置项。 Trigger compaction when estimated token count exceeds this value. |
public Builder reserved(int reserved) | 设置该配置项。 Token buffer reserved for the compaction process (default 20 000). |
public Builder keepMessages(int keepMessages) | 设置该配置项。 Number of recent messages to keep verbatim after compaction. |
public Builder keepTokens(int keepTokens) | 设置该配置项。 Token budget for the preserved tail. |
public Builder keepTokensMin(int keepTokensMin) | 设置该配置项。 Performs the keep tokens min operation. |
public Builder keepTokensMax(int keepTokensMax) | 设置该配置项。 Performs the keep tokens max operation. |
public Builder keepTokensRatio(double keepTokensRatio) | 设置该配置项。 Performs the keep tokens ratio operation. |
public Builder summaryPrompt(String summaryPrompt) | 设置摘要提示词。 Custom summary prompt. |
public Builder flushBeforeCompact(boolean flushBeforeCompact) | 设置该配置项。 Whether to flush long-term memories before compaction (default true). |
public Builder offloadBeforeCompact(boolean offloadBeforeCompact) | 设置该配置项。 Whether to offload raw messages to session JSONL before compaction (default true). |
public Builder truncateArgs(TruncateArgsConfig config) | 设置该配置项。 Enables lightweight pre-summarization argument truncation. |
public Builder prune(PruneConfig config) | 设置修剪。 Configures aggregate tool-result pruning. |
public Builder model(Model model) | 设置模型。 Sets a dedicated model for compaction (summarization), allowing a
lighter/cheaper model than the agent's primary reasoning model. |
public Builder model(String modelId) | 设置模型。 Sets a dedicated model for compaction by model id string
(e.g. |
public CompactionConfig build() | 构建并返回最终实例。 Creates and returns an instance. |
方法详情Method Detail
triggerMessages
public Builder triggerMessages(int triggerMessages)
设置该配置项。
Trigger compaction when conversation has at least this many messages (0 = disabled).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
triggerMessages | int | trigger 消息(类型 `int`)。The trigger messages. |
Builderio/agentscope/harness/agent/memory/compaction/CompactionConfig.java:289–292triggerTokens
public Builder triggerTokens(int triggerTokens)
设置该配置项。
Trigger compaction when estimated token count exceeds this value.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
triggerTokens | int | trigger 令牌数(类型 `int`)。The trigger tokens. |
Builderio/agentscope/harness/agent/memory/compaction/CompactionConfig.java:299–302reserved
public Builder reserved(int reserved)
设置该配置项。
Token buffer reserved for the compaction process (default 20 000).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
reserved | int | reserved(类型 `int`)。The reserved. |
Builderio/agentscope/harness/agent/memory/compaction/CompactionConfig.java:308–311keepMessages
public Builder keepMessages(int keepMessages)
设置该配置项。
Number of recent messages to keep verbatim after compaction.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
keepMessages | int | keep 消息(类型 `int`)。The keep messages. |
Builderio/agentscope/harness/agent/memory/compaction/CompactionConfig.java:314–317keepTokens
public Builder keepTokens(int keepTokens)
设置该配置项。
Token budget for the preserved tail.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
keepTokens | int | keep 令牌数(类型 `int`)。The keep tokens. |
Builderio/agentscope/harness/agent/memory/compaction/CompactionConfig.java:323–326keepTokensMin
public Builder keepTokensMin(int keepTokensMin)
设置该配置项。
Performs the keep tokens min operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
keepTokensMin | int | keep 令牌数最小(类型 `int`)。The keep tokens min. |
Builderio/agentscope/harness/agent/memory/compaction/CompactionConfig.java:328–331keepTokensMax
public Builder keepTokensMax(int keepTokensMax)
设置该配置项。
Performs the keep tokens max operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
keepTokensMax | int | keep 令牌数最大(类型 `int`)。The keep tokens max. |
Builderio/agentscope/harness/agent/memory/compaction/CompactionConfig.java:333–336keepTokensRatio
public Builder keepTokensRatio(double keepTokensRatio)
设置该配置项。
Performs the keep tokens ratio operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
keepTokensRatio | double | keep 令牌数 Ratio(类型 `double`)。The keep tokens ratio. |
Builderio/agentscope/harness/agent/memory/compaction/CompactionConfig.java:338–341summaryPrompt
public Builder summaryPrompt(String summaryPrompt)
设置摘要提示词。
Custom summary prompt.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
summaryPrompt | String | 摘要提示词(类型 `String`)。The summary prompt. |
Builderio/agentscope/harness/agent/memory/compaction/CompactionConfig.java:344–347flushBeforeCompact
public Builder flushBeforeCompact(boolean flushBeforeCompact)
设置该配置项。
Whether to flush long-term memories before compaction (default true).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
flushBeforeCompact | boolean | 刷新之前 Compact(类型 `boolean`)。The flush before compact. |
Builderio/agentscope/harness/agent/memory/compaction/CompactionConfig.java:350–353offloadBeforeCompact
public Builder offloadBeforeCompact(boolean offloadBeforeCompact)
设置该配置项。
Whether to offload raw messages to session JSONL before compaction (default true).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
offloadBeforeCompact | boolean | 卸载之前 Compact(类型 `boolean`)。The offload before compact. |
Builderio/agentscope/harness/agent/memory/compaction/CompactionConfig.java:356–359truncateArgs
public Builder truncateArgs(TruncateArgsConfig config)
设置该配置项。
Enables lightweight pre-summarization argument truncation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
config | TruncateArgsConfig | 配置对象(类型 `TruncateArgsConfig`)。The config. |
Builderio/agentscope/harness/agent/memory/compaction/CompactionConfig.java:365–368prune
public Builder prune(PruneConfig config)
设置修剪。
Configures aggregate tool-result pruning.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
config | PruneConfig | 配置对象(类型 `PruneConfig`)。The config. |
Builderio/agentscope/harness/agent/memory/compaction/CompactionConfig.java:374–377model
public Builder model(Model model)
设置模型。
Sets a dedicated model for compaction (summarization), allowing a lighter/cheaper model than the agent's primary reasoning model.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
model | Model | 模型实例(类型 `Model`)。The model. |
Builderio/agentscope/harness/agent/memory/compaction/CompactionConfig.java:383–386model
public Builder model(String modelId)
设置模型。
Sets a dedicated model for compaction by model id string (e.g.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
modelId | String | 模型标识(类型 `String`)。The model id. |
Builderio/agentscope/harness/agent/memory/compaction/CompactionConfig.java:394–397build
public CompactionConfig build()
构建并返回最终实例。
Creates and returns an instance.
CompactionConfigio/agentscope/harness/agent/memory/compaction/CompactionConfig.java:399–401