Skip to content

feat: enable GitLab Agent Platform with dynamic model discovery#18012

Closed
vglafirov wants to merge 1 commit intoanomalyco:devfrom
vglafirov:dev
Closed

feat: enable GitLab Agent Platform with dynamic model discovery#18012
vglafirov wants to merge 1 commit intoanomalyco:devfrom
vglafirov:dev

Conversation

@vglafirov
Copy link
Copy Markdown
Contributor

Summary

Enable GitLab Agent Platform (Duo Workflow Service) integration with dynamic model discovery, workflow model routing, and local tool execution.

Changes

Package Migration

  • Replaced @gitlab/gitlab-ai-provider v3.6.0 with unscoped gitlab-ai-provider v5.1.2
  • Updated all imports, lockfile entries, and test fixtures to reflect the new package name

Dynamic Model Discovery (provider.ts)

  • Introduced CustomDiscoverModels type and discoveryLoaders registry so providers can dynamically register models at runtime
  • Added discoverModels(providerID) function with a per-provider cache that:
    1. Uses GitLabProjectDetector to detect the current GitLab project from process.cwd()
    2. Resolves the project's namespaceId (group)
    3. Calls GitLabModelDiscovery.discover() to fetch selectable, default, and admin-pinned models for that namespace
    4. Queries GitLabModelConfigRegistry for context/output token limits per model
    5. Registers discovered models as duo-workflow-* entries with full capability metadata (reasoning, attachments, tool calls, image/PDF input)
  • Honors admin-pinned models: when a model is pinned, only that model is available
  • Falls back gracefully when project detection or discovery fails (logs warnings, returns empty)

Workflow Model Routing (provider.ts)

  • GitLab custom model loader now routes duo-workflow-* model IDs through sdk.workflowChat() instead of sdk.agenticChat()
  • Supports a workflowRef option for selecting a specific upstream model reference
  • Static MODEL_MAPPINGS are respected; unknown refs get a generated duo-workflow-{ref} ID
  • Model options are merged and passed through to the model loader ({ ...provider.options, ...model.options })

Workflow Tool Executor (session/llm.ts)

  • When the resolved language model is a GitLabWorkflowLanguageModel, a toolExecutor callback is wired up
  • Tool calls originating from the Duo Workflow Service are executed locally via opencode's tool system
  • Results (including metadata and title) are serialized and sent back over the WebSocket connection
  • Errors are caught and returned as structured error responses

Server Routes (config.ts, provider.ts)

  • Both /config and /provider routes now trigger Provider.discoverModels() for all connected providers before returning responses
  • Discovery errors are caught per-provider and logged as warnings without blocking the response

Feature Flags

  • duo_agent_platform_agentic_chat and duo_agent_platform are enabled by default for GitLab provider

Testing

  • Updated models-api.json test fixture to reflect the new npm package name (gitlab-ai-provider)

@github-actions github-actions bot added contributor needs:compliance This means the issue will auto-close after 2 hours. labels Mar 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Copy Markdown
Contributor

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

Based on my search, I found 1 related PR that should be reviewed:

Related PR:

Why it's related: This PR also addresses GitLab Duo Agent Platform (DAP) workflow model integration. Since #18012 is a more recent implementation with dynamic model discovery and workflow routing, you should verify whether #15573 is already merged, closed, or if there's overlap in the implementation approach that should be consolidated.

@vglafirov vglafirov closed this Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor needs:compliance This means the issue will auto-close after 2 hours.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant