doc/user/duo_agent_platform/agents/external.md
{{< details >}}
{{< /details >}}
{{< collapsible title="Model information" >}}
{{< /collapsible >}}
{{< history >}}
ai_flow_triggers. Enabled by default.ai_catalog_agents. Enabled on GitLab.com.ai_catalog_project_level_enablement. Enabled on GitLab.com, GitLab Self-Managed, and GitLab Dedicated by default.ai_catalog_project_level_enablement removed in GitLab 18.11.{{< /history >}}
[!flag] The availability of this feature is controlled by a feature flag. For more information, see the history.
GitLab Duo agents work in parallel to help you create code, research results, and perform tasks simultaneously.
You can create an agent and integrate it with an external AI model provider to customize it to your organization's needs. Then, in a project issue, epic, or merge request, you can mention that external agent in a comment or discussion and ask the agent to complete a task.
The external agent:
External agents integrate with third-party AI model providers and have different security characteristics than GitLab built-in agents and flows. By using external agents, you accept the following risks:
Before enabling external agents in your organization, review your security requirements and the security documentation provided by your chosen AI model provider.
For a broader overview of security threats and mitigations in the Duo Agent Platform, see the Duo Agent Platform security threats documentation.
{{< details >}}
{{< /details >}}
{{< history >}}
{{< /history >}}
The following integrations have been tested by GitLab and are available:
Before you can create an agent and integrate it with an external AI model provider, you must meet the prerequisites for the GitLab Duo Agent Platform.
Managed external agents can use GitLab-managed credentials and can be enabled in groups without additional agent configuration necessary.
Required steps to enable and use managed agents:
Access the agent in the AI Catalog. Search for the agent name, or use the direct URL.
GitLab-managed external agents display a GitLab-maintained badge ({{< icon name="tanuki-verified" >}}).
Use the external agent in issues, epics or merge requests.
The Claude Code Agent by GitLab uses GitLab-managed credentials and does not require additional configuration. This agent is available only on GitLab.com.
The Codex Agent by GitLab uses GitLab-managed credentials and does not require additional configuration. This agent is available only on GitLab.com.
The Amazon Q Developer Agent does not use GitLab-managed credentials. To use this agent, you must provide your own credentials. This agent is available only on GitLab.com.
To use the Amazon Q Developer Agent:
Add the following environment variables to the CI/CD settings of your project:
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_REGION_NAMEAMAZON_Q_SIGV4The Develop with Gemini Agent does not use the GitLab-managed credentials. To use this agent, you must provide your own credentials. This agent is available only on GitLab.com.
To use the Develop with Gemini Agent:
Add the following environment variables to the CI/CD settings of your project:
GOOGLE_CREDENTIALS - Add the location of the Google credentials JSON file. For details, see GOOGLE_APPLICATION_CREDENTIALS environment variable.GOOGLE_CLOUD_PROJECTGOOGLE_CLOUD_LOCATION{{< details >}}
{{< /details >}}
{{< history >}}
{{< /history >}}
Administrators can add the Claude Agent and Codex Agent to their GitLab instances.
Prerequisites:
To add external agents to your instance:
You can also add external agents with the API.
{{< history >}}
{{< /history >}}
External agents use GitLab-managed credentials through an AI Gateway.
When you use GitLab-managed credentials:
injectGatewayToken: true in your external agent configuration.The following environment variables are automatically injected when injectGatewayToken is true:
AI_FLOW_AI_GATEWAY_TOKEN: the authentication token for AI GatewayAI_FLOW_AI_GATEWAY_HEADERS: formatted headers for API requestsGitLab-managed credentials are available for only Anthropic Claude and OpenAI Codex.
For GitLab-managed credentials, the following AI models are supported:
Anthropic Claude:
claude-haiku-4-5-20251001claude-opus-4-5-20251101claude-opus-4-6claude-sonnet-4-20250514claude-sonnet-4-5-20250929claude-sonnet-4-6OpenAI Codex:
gpt-5gpt-5-codexgpt-5-mini-2025-08-07gpt-5.1gpt-5.1-2025-11-13gpt-5.1-codexgpt-5.2-2025-12-11gpt-5.3-codexgpt-5.4-2026-03-05gpt-5.4-minigpt-5.4-nanoAdd variables to your project to determine how GitLab connects to the third-party provider.
Prerequisites:
To add or update a variable in the project settings:
Type: Select Variable (default).
Environments: Select All (default).
Visibility: Select the desired visibility.
For the API key and personal access token variables, select Masked or Masked and hidden.
Clear the Protect variable checkbox.
Clear the Expand variable reference checkbox.
Description (optional): Enter a variable description.
Key: Enter the environment variable name of the CI/CD variable
(for example, GITLAB_HOST).
Value: The value of the API key, personal access token, or host.
For more information, see how to add CI/CD variables to a project's settings.
The following CI/CD variables are available:
| Integration | Environment variable | Description |
|---|---|---|
| All | GITLAB_TOKEN_<integration> | Personal access token for the service account user. |
| All | GITLAB_HOST | GitLab instance hostname (for example, gitlab.com). |
| Amazon Q | AWS_SECRET_NAME | AWS Secret Manager secret name. |
| Amazon Q | AWS_REGION_NAME | AWS region name. |
| Amazon Q | AMAZON_Q_SIGV4 | Amazon Q Sig V4 credentials. |
| Google Gemini CLI | GOOGLE_CREDENTIALS | JSON credentials file contents. |
| Google Gemini CLI | GOOGLE_CLOUD_PROJECT | Google Cloud project ID. |
| Google Gemini CLI | GOOGLE_CLOUD_LOCATION | Google Cloud project location. |
Enable an agent to trigger it from an issue, merge request, or discussion.
When you enable an agent in a project, it is enabled in the top-level group for that project at the same time.
Prerequisites:
{{< tabs >}}
{{< tab title="From the managing project" >}}
To enable an external agent:
{{< /tab >}}
{{< tab title="From the AI Catalog" >}}
To enable an external agent:
{{< /tab >}}
{{< /tabs >}}
The external agent appears in the group and project Automate > Agents pages. Members of any project in the top-level group can now enable the agent in their project.
A service account is created in the group. The name of the account
follows this naming convention: ai-<agent>-<group>.
If an external agent is already enabled in a top-level group, you can enable it in the group's projects.
Prerequisites:
To enable an external agent in a project:
The external agent appears in the project's Automate > Agents list.
The top-level group's service account is added to the project. This account is assigned the Developer role.
Prerequisites:
In your project, open an issue, merge request, or epic.
Mention, assign, or request a review from the service account user. For example:
@service-account-username Can you help analyze this code change?
After the external agent has completed the task, you see a confirmation, and either a ready-to-merge change or an inline comment.
{{< details >}}
{{< /details >}}
{{< history >}}
ai_catalog_third_party_flows. Enabled on GitLab.com.ai_catalog_create_third_party_flows. Disabled by default.{{< /history >}}
[!flag] The availability of this feature is controlled by a feature flag. For more information, see the history.
On GitLab Self-Managed, if the ai_catalog_create_third_party_flows feature flag is enabled,
you can create an external agent with the AI Catalog and configure it to run in your environment.
On GitLab.com, you cannot create custom external agents. Instead, use a GitLab-managed external agent.
The preferred workflow is:
In this case, a service account is created for you. When the agent runs, it uses a combination of the user's memberships and the service account memberships. This combination is called a composite identity.
If you'd prefer, you can create an external agent manually.
{{< history >}}
{{< /history >}}
When you create a custom external agent, you select a project to manage it and choose whether the agent is public or private.
Public agents:
Private agents:
Start by creating the external agent in the AI Catalog.
Prerequisites:
To create an external agent:
The external agent appears in the AI Catalog.
If you prefer to not follow the UI flow, you can create an external agent manually:
In this case, you manually create the service account that is used to run the agent.
If you create external agents by manually adding configuration files, you must create a different configuration file for each external agent.
Prerequisites:
To create a configuration file:
.gitlab/duo/flows/claude.yamlYou must create a service account that has access to the projects where you expect to use an external agent.
When the agent runs, it uses a combination of the user's memberships and the service account memberships. This combination is called a composite identity.
Prerequisites:
Each project that mentions an external agent must have a unique group service account. Mention the service account username when you assign tasks to the external agent.
If you create an external agent from the AI Catalog and enable it in a top-level group, a service account is automatically created with the name ai-<agent>-<group>. For example, if you enable an agent named Claude code agent in the GitLab Duo group, the service account name is ai-claude-code-agent-gitlab-duo.
[!warning] If you use the same service account across multiple projects, that gives the external agent attached to that service account access to all of those projects.
To set up the service account, take the following actions. If you do not have sufficient permissions, ask your instance administrator or top-level group Owner for help.
For the top-level group, create a service account. Service accounts created for the instance are not supported.
[!note] When you configure an existing service account as an external agent, no personal access tokens can be associated with that account. This behavior is meant to keep service accounts secure.
Create a personal access token for the service account with the following scopes:
write_repositoryapiai_featuresAdd the service account to your project with the Developer role. This ensures the service account has the minimum permissions necessary.
When adding the service account to your project, you must enter the exact name of the service account. If you enter the wrong name, the external agent does not work.
You must now create a trigger, which determines when the external agent runs.
For example, you can specify the agent to be triggered when you mention a service account in a discussion, or when you assign the service account as a reviewer.