Skip to content

feat: integrate GitLab Duo Agent Platform (DAP) workflow models#15573

Closed
vglafirov wants to merge 25 commits intoanomalyco:devfrom
vglafirov:feat/duo-workflow-integration
Closed

feat: integrate GitLab Duo Agent Platform (DAP) workflow models#15573
vglafirov wants to merge 25 commits intoanomalyco:devfrom
vglafirov:feat/duo-workflow-integration

Conversation

@vglafirov
Copy link
Contributor

@vglafirov vglafirov commented Mar 1, 2026

Issue for this PR

Closes #15577

Type of change

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

What does this PR do?

Integrates GitLab Duo Agent Platform (DAP) workflow models into OpenCode alongside existing agentic chat models. Specifically:

  • Routes duo-workflow-* models to workflowChat() in the provider layer with OAuth instance matching via URL normalization
  • Adds dynamic model discovery, a TUI selection picker, and file-based caching for DAP model preferences
  • Wires DWS (Duo Workflow Service) tool executor through OpenCode's permission-gated tool system
  • Handles finish event for workflow model token counting and improves tool-error formatting in the processor
  • Persists enterpriseUrl from OAuth callback for correct instance matching (defaults to https://gitlab.com)
  • Guards sub-model banner display with isWorkflowModel() to prevent stale data for non-workflow models
  • All new files, namespaces, routes, and events use gitlab- prefix to minimize upstream footprint
  • Bumps @gitlab/gitlab-ai-provider from 3.6.0 to 4.0.0

New files:

  • session/gitlab-workflow-model-select.ts — Domain logic: ask/reply/cache for DAP model selection
  • server/routes/gitlab-workflow-model-select.ts — HTTP routes: list, discover, clear, reply
  • tui/component/dialog-gitlab-workflow-model.tsx — TUI dialog for model selection picker

How did you verify your code works?

  • 42 new tests added across 4 test files (all passing):
    • test/session/gitlab-workflow-model-select.test.ts — 14 tests: ask/reply lifecycle, caching, event publishing, concurrent requests
    • test/session/gitlab-workflow-processor.test.ts — 9 tests: finish event handling, tool-error formatting
    • test/provider/gitlab-duo-workflow.test.ts — 10 tests: isWorkflowModel, OAuth instance matching, feature flags
    • test/server/gitlab-workflow-model-select.test.ts — 5 tests: HTTP routes (list, clear, discover, reply)
  • Full test suite passes (1221 tests, 0 failures)
  • Typecheck passes across all 18 packages
  • Manual end-to-end testing with GitLab DAP workflow models

Screenshots / recordings

N/A — no UI changes beyond the model selection picker dialog (terminal TUI).

Checklist

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

Wire GitLab DWS (Duo Workflow Service) workflow models into the
provider and session layers:

- Route duo-workflow-* models to workflowChat() in provider config
- Bridge DWS tool execution requests through OpenCode's tool system
- Use local file reference for gitlab-ai-provider during development
…nd caching

Wire duo-workflow model selection through server routes, TUI dialog,
and Bus events so users can pick from discovered GitLab models with
root namespace resolution, caching, and default fallback.
- Add finish event handler to update usage/cost/tokens
- Use totalUsage from finish event (AI SDK spec)
- Add debug logging for finish event processing
- Fixes token counter not updating for workflow models
…ame default

- Dismiss 'Discovering workflow models...' toast when status is cached, default, or asked
- Rename fallback model name from 'Default' to 'Namespace Default'
- Add namespace fallback via top-level group query when project detection fails
Use GitLabModelCache to persist and restore workflow model selection,
eliminating the discovery toast on startup when a cached selection exists.
The model banner now shows the selected submodel immediately from cache.
…nd fix model banner

Rename all workflow-model-select files, namespaces, routes, and events
to use gitlab- prefix to minimize exposure of GitLab-specific changes.
Fix model banner showing stale sub-model name for non-workflow models
by guarding with isWorkflowModel() check in the parsed memo.
Add comprehensive test suite (42 tests) for gitlab workflow integration.
@vglafirov
Copy link
Contributor Author

✅ APPROVE

After thorough code review and comprehensive testing, this PR is approved for merge.

Test Results

  • 1221 tests passing (0 failures)
  • Typecheck passes across all 18 packages
  • 42 new tests added for GitLab workflow integration
  • No breaking changes to existing functionality

Code Review Summary

Changes Validated:

  1. OAuth Authentication

    • enterpriseUrl || "https://gitlab.com" fallback is correct
    • Test coverage in gitlab-duo-workflow.test.ts:80-96 validates instance matching
    • Existing OAuth users without enterpriseUrl properly default to gitlab.com
    • auth.ts:108-111 correctly persists enterpriseUrl from OAuth callback
  2. Error Handling

    • gitlab-workflow-processor.test.ts includes 9 comprehensive tests
    • Validates all error types: string, Error, object.output, object.message, fallback
    • More robust than original (value.error as any).toString()
  3. Model Banner Display

    • isWorkflowModel() guard prevents stale data display
    • Signal properly scoped to workflow models only
    • Clean separation between workflow and non-workflow models
  4. Backward Compatibility

    • All existing tests pass without modification
    • GitLab-specific code isolated with gitlab- prefix
    • Feature is additive, doesn't modify existing workflows
  5. Code Organization

    • Changes are cohesive: enable GitLab DAP workflow models
    • Well-tested with 42 new tests covering all integration points
    • Properly namespaced to minimize footprint

Key Strengths

  • Comprehensive test coverage (42 new tests)
  • All changes prefixed with gitlab- for isolation
  • Proper OAuth instance URL normalization
  • File-based caching for performance optimization
  • Clean integration with existing tool permission system
  • Handles finish event for workflow model token counting
  • Dynamic model discovery with user selection picker

Files Changed

  • 20 files modified (+2,160 lines, -334 deletions)
  • 3 new files for GitLab workflow model selection
  • 4 new test files with comprehensive coverage

This PR successfully integrates GitLab Duo Agent Platform (DAP) workflow models into OpenCode while maintaining backward compatibility and code quality standards.

Recommendation: Merge 🚀

@vglafirov
Copy link
Contributor Author

@rekram1-node Added review from Agent Platform (Gemini 3.1 Pro Preview - Vertex) GitLab Duo model to help you to make decision on approval. Thanks, this is very important milestone in Gitlab Agent Platform integration.

PS: I also had to recreate PR to comply with your PR standards and use the template, sorry for noise. :)

@vglafirov
Copy link
Contributor Author

E2E tests failures are unrelated to this PR.

@vglafirov vglafirov closed this Mar 2, 2026
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.

[FEATURE]: integrate GitLab Duo Agent Platform (DAP) workflow models

1 participant