GitLab Duo Workflow

Offering: GitLab.com Status: Experiment
History
The availability of this feature is controlled by a feature flag. For more information, see the history. This feature is available for internal GitLab team members for testing, but not ready for production use.

Automate tasks and help increase productivity in your development workflow by using GitLab Duo Workflow.

GitLab Duo Workflow, as part of your IDE, takes the information you provide and uses AI to walk you through an implementation plan.

For the first release, there is only one supported Workflow: write or update code to fix a broken pipeline on a merge request. You can do this from VS Code or by running a cURL command.

Prerequisites

Before you can use GitLab Duo Workflow in VS Code:

  1. Enable the feature duo_workflow feature flag for yourself.
    • In Slack, in the #production channel, type: /chatops run feature set --user=myusername duo_workflow true
    • Or, post a request in the #f_duo_workflow Slack channel.
  2. Install the GitLab Workflow extension for VS Code. Minimum version 5.8.0.
  3. In VS Code, set the Docker socket file path.

Install Docker and set the socket file path

  1. Install Docker:

    brew install docker
    
  2. Install Colima by using Homebrew:

    brew install colima
    
  3. Start Colima:

    colima start
    
  4. Set Docker context:

    docker context use colima
    
  5. Authenticate with the GitLab container registry.

  6. Manually pull the latest version of the Workflow Docker image from the container registry:

    docker pull registry.gitlab.com/gitlab-org/duo-workflow/default-docker-image/workflow-generic-image:v0.0.4
    
  7. Access VS Code settings:
    • On Mac: Cmd + ,
    • On Windows and Linux: Ctrl + ,
  8. In the upper-right corner, select the Open Settings (JSON) icon.
  9. Add this line:

    "gitlab.duoWorkflow.dockerSocket": "/Users/<username>/.colima/default/docker.sock"
    "gitlab.featureFlags.languageServerWebviews": true
    
  10. Save the settings file.

Use GitLab Duo Workflow in VS Code

To use GitLab Duo Workflow:

  1. In VS Code, open the GitLab project and check out the branch for the code you would like to change.
  2. Access the Command Palette:
    • On Mac: Cmd + Shift + P
    • On Windows and Linux: Ctrl + P.
  3. Type Duo Workflow and select GitLab: Show Duo Workflow.
  4. In the Duo Workflow panel, type your command, along with the merge request ID and project ID. Copy-paste is not currently possible.
    • Merge request ID: In GitLab, the ID is in the merge request URL.
    • Project ID: In GitLab, the ID is on the project overview page. In the upper-right corner, select the vertical ellipsis () to view it.

Use cURL to run GitLab Duo Workflow against a CI/CD pipeline

Instead of running GitLab Workflow in VS Code, you can use a cURL command. See the handbook for details.

  1. Create a personal access token with the api scope, or create an OAuth access token with the ai_workflows scope.
  2. Start GitLab Workflow in a CI/CD pipeline by using the following cURL request.

         curl POST --verbose \
         --header 'Authorization: Bearer $YOUR_GITLAB_PAT' \
         --header 'Content-Type: application/json' \
         --data '{
             "project_id": "$PROJECT_ID_FOR_RUNNING_WORKFLOW_AGAINST",
             "start_workflow": true,
             "goal": "Fix the pipeline for merge request X in project Y."
         }' \
         --location 'https://gitlab.com/api/v4/ai/duo_workflows/workflows'
    

The response should be the pipeline ID. To view the pipeline execution, go to:

https://gitlab.com/$namespace/$project/-/pipelines/$pipeline_id

The context Duo Workflow is aware of

GitLab Duo Workflow is aware of the context you’re working in, specifically:

Area How to use GitLab Duo Workflow
Merge requests Enter the merge request ID and project ID in the Duo Workflow panel

In addition, Duo Workflow has read-only access to:

  • The GitLab API for fetching project and merge request information.
  • Merge request’s CI pipeline trace to locate errors in the pipeline job execution.

Current limitations

Duo Workflow has the following limitations:

  • No copy and paste functionality. For details, see issue 380.
  • Execution steps not displayed in UI.
  • Cannot push changes automatically.
  • Manual entry of merge request and project IDs required.
  • No theme support.
  • Project-specific workflow execution only.

Troubleshooting

If you encounter issues:

  1. Check that your open project in VS Code corresponds to the GitLab project you want to interact with.
  2. Ensure that you’ve checked out the branch as well.
  3. Check your Docker and Docker socket configuration:
    1. Follow the setup instructions again.
    2. If using Colima and encountering issues, try restarting it:

      colima stop
      colima start
      
    3. For permission issues, ensure your operating system user has the necessary Docker permissions.
  4. Check the Language Server logs:
    1. To open the logs in VS Code, select View > Output. In the output panel at the bottom, in the top-right corner, select GitLab Workflow or GitLab Language Server from the list.
    2. Review for errors, warnings, connection issues, or authentication problems.
    3. For more output in the logs, open the settings:
      • On Mac: Cmd + ,
      • On Windows and Linux: Ctrl + ,
    4. Search for the setting GitLab: Debug and enable it.
  5. Examine the Duo Workflow Service production LangSmith trace.

Give feedback

Duo Workflow is an experiment and your feedback is crucial. To report issues or suggest improvements, complete this survey.