Skip to content

Conversation

@igorwwwwwwwwwwwwwwwwwwww

Follow-up to #759, now with tests.

Uses @gitlab/gitlab-ai-provider for native tool calling via GitLab's Anthropic proxy. Supports Claude Opus 4.5, Sonnet 4.5, and Haiku 4.5 models.

  • Add gitlab-duo API type and provider
  • Add duo-chat, duo-chat-opus-4-5, duo-chat-sonnet-4-5, duo-chat-haiku-4-5 models
  • Support GITLAB_TOKEN and GITLAB_DUO_TOKEN env vars, as well as oauth
  • No reasoning or image support in upstream (yet)

This is based on the opencode implementation: anomalyco/opencode#7333. I tried to use @gitlab/opencode-gitlab-auth directly, but it takes a dep on @opencode-ai/plugin and I didn't want to drag in all of those transitive deps.

Uses @gitlab/gitlab-ai-provider for native tool calling via GitLab's
Anthropic proxy. Supports Claude Opus 4.5, Sonnet 4.5, and Haiku 4.5
models with automatic OAuth token management.

- Add gitlab-duo API type and provider
- Add duo-chat, duo-chat-opus-4-5, duo-chat-sonnet-4-5, duo-chat-haiku-4-5 models
- Support GITLAB_TOKEN and GITLAB_DUO_TOKEN env vars
- Support self-hosted GitLab via instanceUrl option
- Add streaming support for text, reasoning, and tool calls
Track processed tool call IDs to prevent emitting the same tool call
twice - once from streaming events and again from the final tool-call
event.
- Add loginGitLabDuo and refreshGitLabDuoToken functions
- Add gitlab-duo to OAuth provider list
- Update CLI to handle gitlab-duo login flow
- Support self-hosted GitLab via GITLAB_INSTANCE_URL env var
- Update documentation with OAuth instructions
Use the opencode-gitlab-auth client ID which is registered with
http://127.0.0.1:8080/callback redirect URI. Implements a lightweight
callback server using Node's http module.

The bundled VS Code extension client ID only supports vscode:// scheme
redirects which don't work for CLI applications.
- Add stream.test.ts tests for GitLab Duo provider
- Fix model config: reasoning=false, input=[text] only
- GitLab Duo doesn't support thinking/reasoning mode
- GitLab Duo proxy doesn't support image input
Add gitlab-duo provider tests to:
- abort.test.ts
- context-overflow.test.ts
- empty.test.ts
- tokens.test.ts
- tool-call-without-result.test.ts
- total-tokens.test.ts
- unicode-surrogate.test.ts

Note: image-tool-result.test.ts not updated since GitLab Duo
doesn't support image input.
- Skip cost assertions for gitlab-duo (subscription-based, no per-token cost)
- Skip unpaired surrogate test (GitLab proxy rejects malformed unicode)
- Skip context-overflow test (error patterns may differ from direct Anthropic)
Extract the cause from TOKEN_REFRESH_NEEDED errors to show the actual
API error (e.g., 'prompt is too long: X tokens > Y maximum') instead
of a generic auth failure message.
Sanitize unpaired surrogate characters in system prompts, user messages,
assistant text, and tool results to prevent API errors from malformed
unicode.
The test requires longer timeout due to GitLab proxy latency.
@igorwwwwwwwwwwwwwwwwwwww
Copy link
Author

@badlogic In order to get test credits for an integration test you can go through https://contributors.gitlab.com/start. Please link to this comment if you do.

GitLab team members reading this: Ping me in Slack for more context if needed.

cc @terrorobe

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant