Skip to content

Eviction/prune exclusions match tool names; custom tools sharing built-in names are wrongly exempt #4293

Closed

Description

@Buktal

Problem

Tool-result eviction (ToolResultEvictionConfig) and aggregate pruning (CompactionConfig.PruneConfig) decide exemptions by matching hardcoded tool-name strings:

  • eviction defaults: read_file, write_file, edit_file, memory_search, memory_get
  • prune defaults: read_file, memory_search, memory_get, thread_search

Name matching misfires: a custom tool registered under read_file is silently exempt from eviction and pruning even though it is not the framework's paginated reader — its oversized results stay inline and blow up the context budget. The exemption intent ("this tool's results are small or self-paginating") is a property of the tool, not of its name. The two default lists also differ from each other, which is invisible to users and easy to get wrong when adding tools.

Proposal

Declare the exemption on the tool itself, like readOnly/concurrencySafe:

  • @Tool(evictable = false) / @Tool(prunable = false) (default true), exposed via AgentTool.isEvictable()/isPrunable() and ToolBase.Builder
  • consumers read declarations from the agent's toolkit: ToolResultEvictionMiddleware merges them with excludedToolNames(...); CompactionMiddleware folds them into the effective prune config via withPruneExclusions(...)
  • built-in tools declare themselves, so default protection for them is unchanged
  • the config name lists become user overrides with empty defaults; DEFAULT_EXCLUDED_TOOLS is kept as a deprecated constant for source compatibility

Behavior change: an undeclared custom tool registered under a built-in name is now evicted/pruned like any other tool. Users who deregister tools while their results remain in history can pin names via the config lists.

Activity

  1. added a commit that references this issue on Nov 23, 2026
    029e2d3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions