AS AgentScopeAPI 手册 / API Reference

ToolResultEvictionConfig

public class ToolResultEvictionConfig
源码Source io/agentscope/harness/agent/memory/compaction/ToolResultEvictionConfig.java:43–152

工具结果淘汰配置,保存相关配置项。位于 io.agentscope.harness.agent.memory.compaction 包。核心成员包括 defaults、getMaxResultChars、getPreviewChars、getEvictionPath、getExcludedToolNames、builder。

Configuration for per-tool-result eviction of oversized outputs.

When a tool produces a result whose text content exceeds #getMaxResultChars(), the full output is written to the workspace filesystem abstraction at a deterministic path under #getEvictionPath(), and the in-context io.agentscope.core.message.ToolResultBlock is replaced with a compact placeholder that includes a head+tail preview and an instruction to use readFile for the full content.

This mechanism is orthogonal to conversation summarization (CompactionConfig):

  • Eviction addresses context width — individual messages that are too large.

  • Compaction addresses context depth — too many accumulated messages.

Both operate independently on different trigger conditions and different lifecycle events.

  • Trigger at 80,000 characters (~20 K tokens at 4 chars/token)

  • Preview: first + last 2,000 characters of the original output

  • Eviction path prefix: large_tool_results (relative to the workspace)

  • Excluded tools: filesystem read/write/edit + memory tools (small or self-paginating)

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
Builder类class
`ToolResultEvictionConfig`的构建器。
Builder for `ToolResultEvictionConfig`.

字段摘要Field Summary

字段Field类型Type说明Description
DEFAULT_MAX_RESULT_CHARS
staticfinal
int
默认最大结果字符数字段。
~20 K tokens × 4 chars/token — default eviction threshold.
DEFAULT_PREVIEW_CHARS
staticfinal
int
默认预览字符数字段。
Characters to show at head and tail in the eviction placeholder preview.
DEFAULT_EVICTION_PATH
staticfinal
String
默认淘汰路径字段。
Workspace-relative path prefix under which evicted results are stored.
DEFAULT_EXCLUDED_TOOLS
staticfinal
Set<String>
默认 EXCLUDED 工具字段。
Tools excluded from eviction by default.

方法摘要Method Summary

方法Method说明Description
public static ToolResultEvictionConfig defaults()
static
返回 `defaults` 结果。
Creates a config with all defaults applied.
public int getMaxResultChars()
获取最大结果字符数。
Maximum text length (chars) before eviction fires.
public int getPreviewChars()
获取预览字符数。
Characters to show in the head and tail preview.
public String getEvictionPath()
获取淘汰路径。
Root path under which evicted files are written (e.g.
public Set<String> getExcludedToolNames()
获取 `getExcludedToolNames`。
Tool names that will never be evicted regardless of result size.
public static Builder builder()
static
返回构建器实例。
Returns the builder.

字段详情Field Detail

DEFAULT_MAX_RESULT_CHARS

public static final int DEFAULT_MAX_RESULT_CHARS
staticfinal

默认最大结果字符数字段。声明为 public static final int DEFAULT_MAX_RESULT_CHARS。

~20 K tokens × 4 chars/token — default eviction threshold.

源码Source io/agentscope/harness/agent/memory/compaction/ToolResultEvictionConfig.java:46

DEFAULT_PREVIEW_CHARS

public static final int DEFAULT_PREVIEW_CHARS
staticfinal

默认预览字符数字段。声明为 public static final int DEFAULT_PREVIEW_CHARS。

Characters to show at head and tail in the eviction placeholder preview.

源码Source io/agentscope/harness/agent/memory/compaction/ToolResultEvictionConfig.java:49

DEFAULT_EVICTION_PATH

public static final String DEFAULT_EVICTION_PATH
staticfinal

默认淘汰路径字段。声明为 public static final String DEFAULT_EVICTION_PATH。

Workspace-relative path prefix under which evicted results are stored.

源码Source io/agentscope/harness/agent/memory/compaction/ToolResultEvictionConfig.java:52

DEFAULT_EXCLUDED_TOOLS

public static final Set<String> DEFAULT_EXCLUDED_TOOLS
staticfinal

默认 EXCLUDED 工具字段。声明为 public static final Set DEFAULT_EXCLUDED_TOOLS。

Tools excluded from eviction by default.

源码Source io/agentscope/harness/agent/memory/compaction/ToolResultEvictionConfig.java:66–73

方法详情Method Detail

defaults

public static ToolResultEvictionConfig defaults()
static

返回 defaults 结果。

Creates a config with all defaults applied.

返回Returns ToolResultEvictionConfig
返回ToolResultEvictionConfig。Returns tool result eviction config.
源码Source io/agentscope/harness/agent/memory/compaction/ToolResultEvictionConfig.java:88–90

getMaxResultChars

public int getMaxResultChars()

获取最大结果字符数。

Maximum text length (chars) before eviction fires.

返回Returns int
返回数值结果。Returns a numeric result.
源码Source io/agentscope/harness/agent/memory/compaction/ToolResultEvictionConfig.java:93–95

getPreviewChars

public int getPreviewChars()

获取预览字符数。

Characters to show in the head and tail preview.

返回Returns int
返回数值结果。Returns a numeric result.
源码Source io/agentscope/harness/agent/memory/compaction/ToolResultEvictionConfig.java:98–100

getEvictionPath

public String getEvictionPath()

获取淘汰路径。

Root path under which evicted files are written (e.g.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/memory/compaction/ToolResultEvictionConfig.java:103–105

getExcludedToolNames

public Set<String> getExcludedToolNames()

获取 getExcludedToolNames。

Tool names that will never be evicted regardless of result size.

返回Returns Set<String>
返回设置。Returns set.
源码Source io/agentscope/harness/agent/memory/compaction/ToolResultEvictionConfig.java:108–110

builder

public static Builder builder()
static

返回构建器实例。

Returns the builder.

返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/harness/agent/memory/compaction/ToolResultEvictionConfig.java:112–114

嵌套类详情Nested Class Detail

Builder

public static class Builder

ToolResultEvictionConfig的构建器。位于 io.agentscope.harness.agent.memory.compaction 包。核心成员包括 maxResultChars、previewChars、evictionPath、excludedToolNames、build。

Builder for ToolResultEvictionConfig.

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.