Skip to content

Sync foundational agents from Duo workflow service

What does this MR do and why?

This MR implements the logic to fetch Foundational agents from the Duo Workflow Service (DWS) and store them in the AI Catalog. We've introduced a new item_type: FOUNDATIONAL_AGENT as part of these changes.

Related to &19577

References

Screenshots or screen recordings

Before After

How to set up and validate locally

Gemfile Update (Required for Latest Duo Workflow Client)

To work with the latest version of the gitlab-duo-workflow-service-client gem, you need to update the Gemfile path as follows:

diff --git a/Gemfile b/Gemfile
index fd1370361221f9c..dcdcdf44529943a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -176,7 +176,7 @@ gem 'gitlab-topology-service-client', '~> 0.1',
 
 # Duo Workflow
 gem 'gitlab-duo-workflow-service-client', '~> 0.3',
-  path: 'vendor/gems/gitlab-duo-workflow-service-client',
+  path: '/Users/jaydippansuriya/Documents/projects/gdk/gitlab-ai-gateway/clients/ruby',
   feature_category: :agent_foundations

The run bundle.

  1. Create a sample agent config file at: <gdk>/gitlab-ai-gateway/duo_workflow_service/agent_platform/experimental/flows/configs/security_agent.yml
version: "experimental"
environment: chat-partial
components:
  - name: "Security Agent"
    type: AgentComponent
    prompt_id: "awesome_prompt"
    ui_log_events:
      - "on_agent_final_answer"
    inputs:
      - from: "context:goal"
        as: goal
    toolset:
      - "read_file"
      - "list_dir"
      - "find_files"
      - "grep"
      - "create_file_with_contents"
      - "edit_file"
      - "mkdir"

routers: []
flow: {}

prompts:
  - prompt_id: "awesome_prompt"
    prompt_template:
      system: |
        You are GitLab Duo Chat Security agent, an agentic AI Coding assistant built by GitLab and an expert in security.
        Your role is to help the user complete their request by using the available tools.
        Your response style is concise and actionable.
      user: |
        Here is my task:
        {{goal}}
      placeholder: history
      params:
        timeout: 30
  1. Restart GDK to apply the changes.
  2. Run the sync worker via Rails console:
worker = Ai::Catalog::FoundationFlowsSyncWorker.new
worker.perform
  1. Verify the agent appears under Explore → AI Catalog in the UI.

  2. Confirm the agent is synced for each organization, and that: a. The agentVersion includes correct tools and prompts. b. The configuration matches the definition provided in the .yml.

  3. Query a specific item and its item_type (value for item_type will be FOUNDATIONAL_AGENT):

query get_item {
  aiCatalogItem(id: "gid://gitlab/Ai::Catalog::Item/122") {
    id
    name
    itemType
    latestVersion {
      id
    }
  }
}
  1. Filter catalog items by itemTypes:
query all_agents {
  aiCatalogItems(first: 30, itemTypes: [AGENT, FOUNDATIONAL_AGENT],
  itemType: AGENT) {
    nodes {
      id
      name
      description
      itemType
      project {
        id
      }
      latestVersion {
        id
        releasedAt
        humanVersionName
        ... on AiCatalogAgentVersion {
          systemPrompt
          userPrompt
          tools {
            nodes {
              id
              name
            }
          }
        }
      }
      versions {
        edges {
          node {
            id
            releasedAt
             ... on AiCatalogAgentVersion {
          systemPrompt
          userPrompt
            tools {
              nodes {
                id
                name
                }
              }
            }
          }
        }
      }
    }
  }
}
  1. For a foundational agent, passing its agentVersionId should return the YAML config from Redis.
query get_flow_config {
  aiCatalogAgentFlowConfig(
    agentVersionId: "gid://gitlab/Ai::Catalog::ItemVersion/175"
    flowConfigType: CHAT
  )
}

MR acceptance checklist

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 #573765 (closed)

Edited by Luke Duncalfe

Merge request reports

Loading