Skip to content

[Agentic Chat] Add Codebase Search Tool - workspace active project

Context

As part of supporting "Chat with your codebase" in Agentic Chat, we need to introduce the Codebase Search Tool into it.

This search tool must be able to support codebase search on:

  1. the implicitly included project: the active project in the user's workspace - THIS ISSUE
  2. explicitly included projects: projects included through /include <repository> - addressed [Agentic Chat] Codebase Search Tool - support e... (#569625)

For the sake of iteration, we will only concern ourselves with the first item in this issue.

References

Proposal

Step 1: Add CodebaseSearch as an MCP tool

Add a new MCP tool definition for CodebaseSemanticSearch

Codebase Semantic Search invocation

Note: the feasibility of the above approaches are still under discussion. There are a few concerns including security. Please refer to the discussions in SPIKE: Discuss API tool design for MCP tool (#569206)

Step 2: Make sure that the CodebaseSearch tool is correctly invoked by Agentic Chat

Given a user question, Agentic Chat should be able to correctly invoke the CodebaseSearch tool for the workspace's active project.

This includes testing that:

  • the CodebaseSearch tool is invoked for questions related to the project code
  • the CodebaseSearch tool is NOT invoked for questions unrelated to the project code

Further considerations

Tool call / parameters

As indicated in the title, we will only support a query on a single project for this issue.

For further exploration:

  • Consider making use of the AI model to extract the best search_term for the API from the user's question. For example, if the user question is "How do I create an ActiveRecord migration?", the tool may extract "create an ActiveRecord migration" as the search_term to send to the API
  • Consider making use of the AI model to determine the knn and limit needed for the search
Edited by Pam Artiaga