[Spike] Test OpenCode CLI Integration with GitLab Duo Self-Hosted
In 18.3, the Duo Agent Platform team announced the beta of CLI Agents in GitLab CI/CD. Of the CLI Agents offered, only OpenCode is available as an airgapped offering. We need to verify that the OpenCode AI CLI agent integration works properly with GitLab Self-Hosted instances. This test will validate the complete workflow from setup to execution.
Test Scope
Environment Requirements
- GitLab Self-Managed instance (latest)
- GitLab Ultimate subscription with GitLab Duo Enterprise add-on
- GitLab Duo Self-Hosted configuration with:
- Self-hosted AI gateway
- Supported local models
- Active GitLab Runner for CI/CD execution
Prerequisites to Validate
- Beta and experimental features are enabled
- GitLab Duo is properly configured and functional
- Self-hosted models are properly configured
- GitLab Runner is available and functional
CI/CD Variable Configuration
- Configure required environment variables in project settings:
-
ANTHROPIC_API_KEY(orOPENAI_API_KEYdepending on model)GITLAB_TOKEN_OPENCODE(service account token)GITLAB_HOST(GitLab instance hostname)
- Verify variables are masked and properly configured
-
Flow Configuration File
- Create
.gitlab/duo/flows/opencode.yamlwith proper OpenCode configuration- Validate the configuration includes:
- OpenCode AI installation (
npm install --global opencode-ai) - glab CLI installation and authentication
- Git configuration
- Proper authentication setup for OpenCode
- Command execution with GitLab context variables
- OpenCode AI installation (
- Validate the configuration includes:
Flow Trigger Setup
- Create flow trigger in project settings
- Configure trigger for "Mention" event type
- Link to service account user and flow configuration file
- Verify trigger appears in Automate > Flow triggers
End-to-End Workflow Testing
- Create test issue in project
- Mention the OpenCode service account with a simple task (e.g., "@opencode-agent can you analyze the current repository structure?")
- Verify pipeline starts and "Processing the request" message appears
- Monitor CI/CD pipeline execution and logs
- Confirm OpenCode AI successfully:
- Connects to self-hosted models
- Authenticates with GitLab API
- Executes requested task
- Provides response in issue comment
Error Handling and Edge Cases
- Test with invalid/expired API keys
- Test with insufficient permissions
- Test with complex multi-step tasks
- Test with code modification requests
- Verify proper error messages and logging
Definition of Done
- Test environment details are documented:
- GitLab Version:
- GitLab Duo Self-Hosted Version:
- AI Gateway Version:
- Model Backend: (e.g., vLLM)
- Specific Model:
- Runner Type: (Docker, Kubernetes, Shell)
- Self-Hosted customers can set up OpenCode for use within GitLab
- OpenCode CLI agent responds to mentions in issues/MRs
- Pipeline executes without errors
- Agent can read repository context and GitLab data via glab CLI
- Agent provides meaningful responses using self-hosted models
- All authentication flows work with self-hosted configuration
- Changes are properly committed and pushed when applicable
- Any potential issues are documented:
- Authentication failures with self-hosted models
- OpenCode configuration incompatibilities
- CI/CD pipeline failures specific to self-hosted setup
- Performance issues with local model inference
- Network connectivity problems in isolated environments
- Documentation is updated (as appropriate):
- GitLab Duo Self-Hosted setup documentation
- OpenCode CLI agent configuration examples
- Troubleshooting guides for self-hosted environments
- Known limitations
Edited by 🤖 GitLab Bot 🤖