Add exclude_types to the get_agent_flows query

What does this MR do and why?

Add exclude_types to the get_agent_flows query to fix the sessions pagination, details on the bug in #578969 (comment 3082342357). Foundational chat agent names are taken from foundational_chat_agent_definition.rb

References

#578969 (closed)

Screenshots or screen recordings

Before After

How to set up and validate locally

  1. Ensure your GDK project has some of the foundational_chat_agents sessions.

  2. Go to Automate > Sessions, you should see the next page missing from pagination

  3. Pull from this branch and reload sessions page, you should be able to see next page option

  4. Alternatively, you can also try the below graphql

    Before After
    Query
    
    query getAgentFlows(
      $projectPath: ID!
      $after: String
      $before: String
      $first: Int
      $last: Int
      $search: String
      $sort: DuoWorkflowsWorkflowSort
      $statusGroup: DuoWorkflowStatusGroup
      $type: String
    ) {
      project(fullPath: $projectPath) {
        id
        duoWorkflowWorkflows(
          projectPath: $projectPath
          first: $first
          after: $after
          last: $last
          before: $before
          search: $search
          sort: $sort
          statusGroup: $statusGroup
          type: $type
        ) {
          pageInfo {
            startCursor
            endCursor
            hasNextPage
            hasPreviousPage
          }
          edges {
            node {
              ...FlowFragment
            }
          }
        }
      }
    }
    
    fragment FlowFragment on DuoWorkflow {
      id
      status
      humanStatus
      createdAt
      updatedAt
      workflowDefinition
      userId
      latestCheckpoint {
        duoMessages {
          content
          messageType
        }
      }
      userPermissions {
        updateDuoWorkflow
      }
      project {
        id
        name
        webUrl
        namespace {
          id
          name
          webUrl
        }
      }
    }
    
     query getAgentFlows(
      $projectPath: ID!
      $after: String
      $before: String
      $first: Int
      $last: Int
      $search: String
      $sort: DuoWorkflowsWorkflowSort
      $statusGroup: DuoWorkflowStatusGroup
      $type: String
      $excludeTypes: [String!]
    ) {
      project(fullPath: $projectPath) {
        id
        duoWorkflowWorkflows(
          projectPath: $projectPath
          first: $first
          after: $after
          last: $last
          before: $before
          search: $search
          sort: $sort
          statusGroup: $statusGroup
          type: $type
          excludeTypes: $excludeTypes
        ) {
          pageInfo {
            startCursor
            endCursor
            hasNextPage
            hasPreviousPage
          }
          edges {
            node {
              ...FlowFragment
            }
          }
        }
      }
    }
    
    fragment FlowFragment on DuoWorkflow {
      id
      status
      humanStatus
      createdAt
      updatedAt
      workflowDefinition
      userId
      latestCheckpoint {
        duoMessages {
          content
          messageType
        }
      }
      userPermissions {
        updateDuoWorkflow
      }
      project {
        id
        name
        webUrl
        namespace {
          id
          name
          webUrl
        }
      }
    }
    
    Variables
    {
      "projectPath": "gitlab-org/gitlab",
      "before": null,
      "after": null,
      "first": 20,
      "last": null,
      "sort": "UPDATED_DESC",
      "statusGroup": null,
      "type": null
    }
    
    {
      "projectPath": "gitlab-org/gitlab",
      "before": null,
      "after": null,
      "first": 20,
      "last": null,
      "sort": "UPDATED_DESC",
      "statusGroup": null,
      "type": null,
      "excludeTypes": ["analytics_agent/v1", "security_analyst_agent/v1", "duo_planner/v1"]
    }
    
    Output
    {
      "data": {
        "project": {
          "id": "gid://gitlab/Project/278964",
          "duoWorkflowWorkflows": {
            "pageInfo": {
              "startCursor": "MQ",
              "endCursor": "MTrk",
              "hasNextPage": false,
              "hasPreviousPage": false
            },
            "edges": [ {...}] // should have less than 20 values if any foundational chat agent is in the last 20 sessions
          }
        }
      }
    }
    {
      "data": {
        "project": {
          "id": "gid://gitlab/Project/278964",
          "duoWorkflowWorkflows": {
            "pageInfo": {
              "startCursor": "MQ",
              "endCursor": "MjA",
              "hasNextPage": true,
              "hasPreviousPage": false
            },
            "edges": [ {...}] // should contain exact 20 values
          }
        }
      }
    }

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

Edited by Surabhi Suman

Merge request reports

Loading