Class ToolResultEvictionConfig

java.lang.Object
io.agentscope.harness.agent.memory.compaction.ToolResultEvictionConfig

public class ToolResultEvictionConfig extends Object
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 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
  • Excluded tools: filesystem read/write/edit/list + memory tools (small or self-paginating)
  • Field Details

    • DEFAULT_MAX_RESULT_CHARS

      public static final int DEFAULT_MAX_RESULT_CHARS
      ~20 K tokens × 4 chars/token — default eviction threshold.
      See Also:
    • DEFAULT_PREVIEW_CHARS

      public static final int DEFAULT_PREVIEW_CHARS
      Characters to show at head and tail in the eviction placeholder preview.
      See Also:
    • DEFAULT_EVICTION_PATH

      public static final String DEFAULT_EVICTION_PATH
      Root path prefix under which evicted results are stored.
      See Also:
    • DEFAULT_EXCLUDED_TOOLS

      public static final Set<String> DEFAULT_EXCLUDED_TOOLS
      Tools excluded from eviction by default.
      • read_file — evicting would cause re-read loops; pagination handles size
      • write_file, edit_file — return tiny success messages
      • grep_files, glob_files, list_files — self-limiting outputs
      • memory_search, memory_get, session_search — small/paginated results
      Shell (execute) is intentionally NOT excluded: command output can be very large.
  • Method Details

    • defaults

      public static ToolResultEvictionConfig defaults()
      Creates a config with all defaults applied.
    • getMaxResultChars

      public int getMaxResultChars()
      Maximum text length (chars) before eviction fires.
    • getPreviewChars

      public int getPreviewChars()
      Characters to show in the head and tail preview.
    • getEvictionPath

      public String getEvictionPath()
      Root path under which evicted files are written (e.g. /large_tool_results).
    • getExcludedToolNames

      public Set<String> getExcludedToolNames()
      Tool names that will never be evicted regardless of result size.
    • builder

      public static ToolResultEvictionConfig.Builder builder()