Skip to content

search_code returns too verbose payloads #431

@localconst

Description

@localconst

Currently, the search_code tool, in addition to returning search results, also includes Git items with the entire file content.

Here:

const combinedResults = await fetchCombinedResults(resultJson.results ?? [], gitApi);

This makes the output too verbose for agents and can significantly impact performance, especially in large repositories when many large files are matched.

I propose 2 options to reduce the size of the payloads returned by this tool:

Option 1, simple

Add a new flag to the search_code to control whether to include Git items with full content.

  • If it's OFF - don't call the fetchCombinedResults
  • This allows agents to choose between full details or only search results.
  • If needed, they can make a follow-up call using other tool to retrieve the full Git item content.
  • It can be named somehow like includeGitItems
  • IMHO, should be off by default.

Option 2, more advanced

I see that few fields are duplicated in search results and git items, so they can be merged together:

  • results.contentId == gitItem.objectId
  • gitItem.commitId already exists in search result, so no need to duplicate it.
  • file paths

For files content, we can add a new argument includeFilesContent to control whether to include file content in the response.
And we can remap the gitItem.content field to object with lengh and data fields:

  • if includeFilesContent is OFF, then only content length will be returned, so agent can decide whether it's worth to fetch data separately.
  • if ON, the data field will contain the full file content. Same as for now, but also including content's length.

This option allows us to keep all useful metadata but reduce payload


Please share your thoughts about this. Thanks!

P.S.
I’m not sure if TFVC supports code search, as I don’t use it. If yes, will these Git item calls always fail for TFVC repos?

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions