Skip to content

Conversation

@PrasangAPrajapati
Copy link

@PrasangAPrajapati PrasangAPrajapati commented Sep 17, 2025

Related GitHub Issue

Closes: #8087

Roo Code Task Context (Optional)

Description

  • Added IBM watsonx AI provider in the list of providers in the Roo Code VS Code extension to connect to IBM watsonx-hosted LLMs.
  • Added IBM watsonx AI provider in the list of embedded providers in the Roo Code VS Code extension to connect to IBM watsonx-hosted embedded models for code-indexing...

Test Procedure

  • You can start with the free trial: https://dataplatform.cloud.ibm.com/registration/stepone?context=wx
  • Sign up with Google (Do not use RedHat) - If you already have an account, just use Log In
  • Once you're logged in to the IBM Cloud, you'll be asked to add the address and the credit card information (Don't worry, you won't get charged)
  • Go to the Resources list from the left sidebar menu
  • Click on the Create resource button
  • Go to the Category - AI/Machine Learning
  • Click on watsonx.ai runtime
  • Select the Region (Dallas) and Lite plan, which is free
  • You can give the service name, and the resource group will be the default.
  • Accept terms and conditions and hit create
  • Now there is a button called Launch In -> Select IBM watsonx from the drop-down - it will create a watsonx instance
  • Go down on the page and create a project by clicking on the + icon (it may create automatically)
  • Go to Manage and click on the Services and integrations from the left menu bar (make sure the created watsonx.ai runtime is associated)
  • Go back to the home page by clicking on the top left IBM watsonx
  • Select your project from the drop-down shown in the Developer access area
  • Click on the Create API key and save the API key (you won't be able to see that again)
  • Note project ID and api key
  • Use the project ID and api key in the Roo Code IBM watsonx provider

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Screenshot 2025-09-17 at 6 08 27 PM Screenshot 2025-09-17 at 6 08 18 PM

Documentation Updates

Additional Notes

Get in Touch

  • Let's use the GH PR only for communication.

Important

This PR adds IBM watsonx as a new AI provider, including configuration, validation, UI integration, and testing support.

  • Behavior:
    • Adds IBM watsonx as a new AI provider in provider-settings.ts and index.ts.
    • Supports both IBM Cloud and Cloud Pak platforms with different authentication methods.
    • Integrates model fetching and embedding capabilities.
  • Validation:
    • Updates validate.ts to include validation for IBM watsonx API keys, project ID, and platform-specific settings.
  • UI:
    • Adds UI components for IBM watsonx configuration in CodeIndexPopover.tsx and ApiOptions.tsx.
    • Updates localization files for new settings in ko, nl, and pt-BR.
  • Testing:
    • Adds tests for IBM watsonx in watsonx.spec.ts and embedders/watsonx.spec.ts.

This description was created by Ellipsis for 8e0e30c. You can customize this summary. It will automatically update as commits are pushed.

Copy link
Contributor

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! I've reviewed the changes and found several issues that need attention before this can be merged. The implementation adds IBM watsonx AI provider support, but there are some critical missing pieces and unrelated changes that should be addressed.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 17, 2025
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Sep 22, 2025
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:XXL This PR changes 1000+ lines, ignoring generated files. labels Sep 22, 2025
@hannesrudolph hannesrudolph moved this from PR [Changes Requested] to PR [Needs Prelim Review] in Roo Code Roadmap Sep 23, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found some issues that need attention. See the inline comments for details.

}

this.service = WatsonXAI.newInstance(serviceOptions)
this.service.getAuthenticator().authenticate()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Unawaited authenticator.authenticate() in a non-async constructor risks a race and unhandled rejection. Either remove and rely on lazy auth, await in an async factory, or defer auth to the first API call.

let embedding = response.result.results[0].embedding
if (!embedding || embedding.length === 0) {
console.error(`Empty embedding returned for text at index ${textIndex}`)
const expectedDimension = this.getExpectedDimension(modelToUse)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Generating fallback embeddings (0.0001-filled vectors) pollutes the index and harms retrieval. Prefer surfacing an error and skipping the item (with logging) so quality isn’t degraded.

detailedMessage = `Connection failed: ${errorMessage}. Please check your network connection and base URL.`
}

await vscode.window.showErrorMessage(detailedMessage)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Provider layer shouldn’t call VS Code UI (window.showErrorMessage). Emit an error event/result and let UI handle display to keep layers separated and enable headless usage.

throw new Error("Base URL is required for IBM Cloud Pak for Data")
}

if (username) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] For Cloud Pak, if the username (and corresponding auth) is missing, the client is created without authenticator and the call will fail later. Validate required fields up front and return an error.


async createEmbeddings(texts: string[], model?: string): Promise<EmbeddingResponse> {
const MAX_RETRIES = 3
const INITIAL_DELAY_MS = 1000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Hardcoded delays/rate limits (INITIAL_DELAY_MS/REQUEST_DELAY_MS/MAX_CONCURRENT_REQUESTS) will either throttle too much or still trip 429s. Make these configurable and consider adaptive backoff using response headers.

baseUrl = apiConfiguration.watsonxBaseUrl || ""
}

if (platform === "ibmCloud" && (!apiKey || !baseUrl)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Refresh Models for IBM Cloud proceeds without validating projectId; downstream requests that require projectId will fail. Block the action until projectId is provided.

const platform = this.options.watsonxPlatform

try {
const serviceOptions: any = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] serviceOptions typed as any; replace with the SDK’s options type to improve maintainability and compile-time safety.

password?: string,
): Promise<Record<string, ModelInfo>> {
try {
let options: any = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] options typed as any here and below; add concrete types for SDK client configuration and response mapping (model spec shape).

import type { ModelInfo } from "../model.js"

export type WatsonxAIModelId = keyof typeof watsonxAiModels
export const watsonxAiDefaultModelId = ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Empty default model id can lead to runtime calls with an empty model id if validation is bypassed. Prefer a safe explicit default (e.g., ibm/granite-3-3-8b-instruct) or require selection.

defaultModelId={watsonxAiDefaultModelId}
models={watsonxModels && Object.keys(watsonxModels).length > 0 ? watsonxModels : {}}
modelIdKey="watsonxModelId"
serviceName=""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] ModelPicker serviceName/serviceUrl are empty; populate to improve UX and consistency with other providers.

@daniel-lxs daniel-lxs closed this Sep 25, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 25, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Prelim Review] to Done in Roo Code Roadmap Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PR - Needs Preliminary Review size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Add IBM watsonx AI provider in the list of providers to connect to IBM hosted LLMs

3 participants