Skip to content

[Bug]: session_search results are unbounded in size and excluded from tool-result eviction #4098

Closed

Description

@guslegend0510

Describe the bug
session_search caps the number of matches (#3270 / #3382, max 100), but not their size. Each match carries the whole stored message, so a few matches that contain large tool outputs can produce a very large result. At the same time session_search is in ToolResultEvictionConfig.DEFAULT_EXCLUDED_TOOLS, so the eviction middleware never offloads it. The oversized result stays inline and can push the next model request over the input budget.

To Reproduce

  1. Run a HarnessAgent long enough that several earlier tool results (e.g. large JSON API responses) are in the session log.
  2. Have the agent call session_search with a keyword that matches those messages.
  3. The tool returns all matching messages inline; with default eviction settings nothing trims it.

Observed in a benchmark run: 12 matches, ~143K characters in a single session_search result (one message alone ~80K serialized chars). Context compaction could not bring it under budget and the request was rejected.

Expected behavior
Oversized session_search results should be offloaded like other large tool outputs (head/tail preview + read_file pointer), while small results stay inline.

Additional context

Environment

  • AgentScope-Java Version: 2.1.0-SNAPSHOT (main 874c9cb)
  • Java Version: 17

Activity

  1. added a commit that references this issue on Nov 13, 2026
    36cabf4
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