Draft: feat: add run glql query tool
What does this merge request do and why?
Adds a tool that executes a GitLab Query Language (GLQL) query and returns the results.
Important: This tool is dependant on a monolith MR Draft: Create a new GLQL REST API for Duo integ... (gitlab-org/gitlab!209517) planned for 18.6
Related issue: Create a tool in DAP that calls the GLQL API (gitlab-org/gitlab#578243)
Additional context: This change is required to launch the GitLab Analytics Agent MVC for GitLab Analytics Agent (gitlab-org&19500)
Screen recording
How to set up and validate locally
To validate this tool in your GDK:
- Follow this guide and check out this branch on AI gateway
- Register the new tool in GitLab by applying the patch below in your
gdk/gitlabdir - Restart your GDK
- Navigate to
[GDK_HOST]/explore/ai-catalog/agentsand create a test agent and add theRun GLQL querytool - In agentic chat, ask your test agent what tools it has and it should respond with
Run GLQL query - For e2e validation, check out gitlab-org/gitlab!209517 and update your test agent to use this prompt to enable GLQL generation and trigger this tool using analytical questions, eg:
How many MRs are in this project?How many issues are in this group?
Click to expand
diff --git a/ee/lib/ai/catalog/built_in_tool_definitions.rb b/ee/lib/ai/catalog/built_in_tool_definitions.rb
index 0bfee4f3117f..aed7da31174d 100644
--- a/ee/lib/ai/catalog/built_in_tool_definitions.rb
+++ b/ee/lib/ai/catalog/built_in_tool_definitions.rb
@@ -801,6 +801,24 @@ module BuiltInToolDefinitions
"- Given group_id 'namespace/group' and title \"Implement feature X\", the tool call would be: " \
"create_work_item(group_id='namespace/group', title=\"Implement feature X\", type_name=\"issu" \
"e\")"
+ },
+ {
+ id: 76,
+ name: "run_glql_query",
+ title: "Run GLQL Query",
+ description: "Execute a GitLab Query Language (GLQL) query and return structured results. " \
+ "GLQL allows you to search and filter GitLab issues, merge requests, and more using a " \
+ "simple query syntax. Provide a complete GLQL query block including the query parameter " \
+ "(required) and optional parameters like display format, fields to return, sorting, and limit. " \
+ "The query is transformed internally to GraphQL and returns structured data with pagination support. " \
+ "Example GLQL query: " \
+ "```glql " \
+ "display: table " \
+ "fields: title, state, author, created " \
+ "sort: created desc " \
+ "limit: 50 " \
+ "query: type = Issue and state = opened and project = \"namespace/project\" " \
+ "``` "
}
].freeze
end
Merge request checklist
-
Tests added for new functionality. If not, please raise an issue to follow up. -
Documentation added/updated, if needed. -
If this change requires executor implementation: verified that issues/MRs exist for both Go executor and Node executor or confirmed that changes are backward-compatible and don't break existing executor functionality.
Edited by Jiaan Louw