Skip to content

feat: enable GitLab Agent Platform with workflow model discovery#18014

Merged
rekram1-node merged 24 commits intoanomalyco:devfrom
vglafirov:dev
Mar 20, 2026
Merged

feat: enable GitLab Agent Platform with workflow model discovery#18014
rekram1-node merged 24 commits intoanomalyco:devfrom
vglafirov:dev

Conversation

@vglafirov
Copy link
Copy Markdown
Contributor

@vglafirov vglafirov commented Mar 18, 2026

Issue for this PR

Enables GitLab Agent Platform support with dynamic workflow model discovery.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This PR adds full support for the GitLab Agent Platform in opencode, including dynamic workflow model discovery and tool execution over WebSocket.

Key changes:

  1. Package migration: Replaced @gitlab/gitlab-ai-provider (v3.6.0) with the renamed gitlab-ai-provider (v5.2.0) — the package was moved out of the @gitlab npm scope.

  2. Dynamic workflow model discovery (provider.ts):

    • Added a new CustomDiscoverModels type and discoverModels field to the custom provider loader interface.
    • The GitLab provider loader now implements discoverModels(), which calls discoverWorkflowModels() from the SDK. This queries the GitLab instance for available workflow models based on the current project context (working directory / git remote).
    • Discovered models are registered as first-class provider models with proper capabilities (reasoning, tool calls, attachments, image/PDF input).
    • Discovery results are cached per provider to avoid redundant API calls.
  3. Workflow model routing (provider.ts):

    • Models with IDs starting with duo-workflow- are routed through sdk.workflowChat() instead of sdk.agenticChat().
    • The isWorkflowModel() utility from the SDK determines whether a static mapping exists; otherwise falls back to duo-workflow with a selectedModelRef.
    • Model-level options (e.g. workflowRef) are now merged and passed through to the model loader.
  4. Tool executor wiring (session/llm.ts):

    • When the active language model is a GitLabWorkflowLanguageModel, a toolExecutor callback is attached. This allows the remote workflow service to invoke opencode's local tools (file read/write, shell, etc.) and receive results back over the WebSocket connection.
  5. Lazy discovery in API routes (server/routes/config.ts, server/routes/provider.ts):

    • Both the config and provider API endpoints now trigger Provider.discoverModels() for all connected providers before returning the provider list, ensuring freshly discovered models appear in the UI.
  6. Feature flags: The duo_agent_platform and duo_agent_platform_agentic_chat feature flags are now set by default for all GitLab provider requests.

How did you verify your code works?

  • Verified the package installs correctly with the new gitlab-ai-provider dependency.
  • Tested against a GitLab instance with Agent Platform enabled — workflow models are discovered and appear in the model selector.
  • Confirmed that selecting a workflow model routes through workflowChat() and tool calls from the workflow service execute locally via the toolExecutor bridge.
  • Verified that existing agenticChat models continue to work unchanged.

Screenshots / recordings

N/A — backend/provider changes, no UI modifications.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential duplicate PR found:

Consider reviewing PR #15573 to check:

vglafirov and others added 18 commits March 19, 2026 16:19
Route handlers were triggering discoverModels for all connected
providers, causing unnecessary network calls and potential hangs.
Only the gitlab provider has a discovery loader, so restrict the
call to gitlab when it is connected.
- Add experimental notice and license requirements
- Update admin setup instructions with current GitLab docs links
- Remove hardcoded featureFlags from config example
- Add DAP workflow models documentation section
- Migrate npm package references to unscoped names
- Apply changes across English and 17 translated locales
Replace @gitlab/opencode-gitlab-auth@1.3.3 with opencode-gitlab-auth@2.0.0.
…gitlab-ai-provider to 5.2.2

Move discoverModels call from config.ts and provider.ts routes into
state() initialization so discovery runs once at startup. Upgrade
gitlab-ai-provider to 5.2.2 which caches discovery results to disk
with a 10-minute TTL, avoiding redundant GraphQL calls.
Discovery now runs inside state() init, making the exported
discoverModels() and its cache dead code. Remove both along
with the corresponding tests.
@rekram1-node rekram1-node merged commit 05d3e65 into anomalyco:dev Mar 20, 2026
9 checks passed
@rekram1-node
Copy link
Copy Markdown
Collaborator

Note to self:

We are merging for now to unblock gitlab, later we should move all this logic so that it can be done via plugin hooks rather than hardcoding provider specific logic in places like llm.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants