Update code generation prompts to limit number of libraries included

What does this MR do and why?

Background:

The Repository X-Ray is a feature that scans a project's repository for dependency config files and then parses a list of libraries from the file content. The libraries are then included into the code generation prompt to improve code suggestions.

Context:

In #500365 (closed), we observed that there is no limit applied to the number of libraries included in the code generation prompt. This means that we may be sending very large or significantly truncated prompts to the LLM. Using a basic distribution analysis as described in #500365 (comment 2186343162), we determined that the limit should be set to 300 as a first iteration.

This MR:

Applies the libraries limit to both the legacy code generation prompt (anthropic_messages.rb) as well as in the libraries parameter that we send to the new AIGW v3 endpoint (ai_gateway_messages.rb)

Resolves #500365 (closed).

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #500365 (closed)

Merge request reports

Loading