holmesgpt icon indicating copy to clipboard operation
holmesgpt copied to clipboard

Add optional grep parameter to all tools for context window optimization

Open aantn opened this issue 6 months ago • 3 comments

Motivation

Currently, when HolmesGPT runs investigations, it often loads all relevant data upfront from tools, which can lead to large context windows. In contrast, coding agents like Claude Code typically start with grep operations or read limited file subsets to keep context manageable, then requests more data as needed.

We should try the same approach for us, to see if it helps with keeping context windows from overflowing, thereby causing truncation.

General Idea

We should add an optional grep parameter to every tool that allows the LLM to filter tool outputs on-demand. This would enable the LLM to:

  • Request only relevant portions of large tool outputs initially
  • Follow up with additional grep patterns or full data as needed

Implementation Approach

This could potentially be implemented using the upcoming transformers API as a "grep transformer" that:

  • Adds grep parameters visible to the LLM for all tools
  • Applies filtering to tool outputs based on LLM-specified patterns
  • Maintains backward compatibility with existing toolsets

aantn avatar Jun 28 '25 07:06 aantn

Hey @aantn, just to confirm my understanding, the issue seems to be that we're hitting context size limitations because all tools are being loaded into the context upfront. We're exploring a way to load tools dynamically to address this, right?

I came across this approach it might be helpful https://www.youtube.com/watch?v=3ISRS2hQlfI

mrchocha avatar Jul 19 '25 12:07 mrchocha

Hey @aantn, just to confirm my understanding, the issue seems to be that we're hitting context size limitations because all tools are being loaded into the context upfront. We're exploring a way to load tools dynamically to address this, right?

I came across this approach it might be helpful https://www.youtube.com/watch?v=3ISRS2hQlfI

If this is the way you are looking for then can i give it a try? would love to work on this.

mrchocha avatar Jul 19 '25 12:07 mrchocha

@mrchocha not exactly! The issue here is a bit tricker and its about the actual output from tools exceeding context windows. Its probably not the best beginner issue to look at!

aantn avatar Jul 20 '25 07:07 aantn