Skip to content

Conversation

@iskandarsulaili
Copy link

@iskandarsulaili iskandarsulaili commented Nov 13, 2025

Description

This PR implements a comprehensive Azure API Provider for Roo Code, supporting all Azure AI Foundry and Azure OpenAI services, including all current and future GPT-5 variants. The provider features:

  • Hierarchical endpoint logic for both Azure OpenAI and Foundry patterns.
  • Full support for both API key and Azure Active Directory (AAD) authentication.
  • Forward-compatible model registry: users can select any available model from a dropdown or manually enter a deployment/model name.
  • Robust error normalization for Azure-specific errors (rate limits, permission denied, deployment/model not found, quota exceeded).
  • Integration with the Roo Code provider registry and model picker UI.
  • Extensive tests for all endpoints, authentication flows, and model variants.
  • Documentation of non-obvious implementation details and gotchas.

Key design choices:

  • The UI leverages a searchable dropdown for all available models and allows manual entry for custom deployments (see ModelPicker.tsx).
  • The provider is architected for forward compatibility with new Azure/Foundry models and API versions.

Test Procedure

  • Unit tests for the Azure provider are in src/api/providers/__tests__/azure.spec.ts.
  • Tests cover:
    • API key and AAD authentication (mocked).
    • Endpoint URL construction for both OpenAI and Foundry.
    • Model registry logic for known and unknown (future) model IDs, including GPT-5 variants.
    • Error normalization for all major Azure error types.
  • Manual testing:
    • In the settings UI, select the Azure provider.
    • Choose a model from the dropdown or type a custom deployment/model name.
    • Verify completions and error handling for various scenarios (rate limit, permission denied, etc.).
    • Test both API key and AAD authentication flows.

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

  • The model picker UI allows both dropdown selection and manual entry for Azure models:
    • ModelPicker Dropdown and Custom Entry
  • Example: User types a custom deployment/model name and selects it:
    • Custom Model Entry

Documentation Updates

  • No documentation updates are required.
  • Yes, documentation updates are required. (Please describe what needs to be updated or link to a PR in the docs repository).

Additional Notes

  • The provider is robust against future Azure API/model changes.
  • All non-obvious implementation details are documented in .roo/rules-code/azure-provider-gotchas.md.
  • If reviewers have questions about the UI or provider logic, see ModelPicker.tsx for the dropdown/custom entry implementation.

Get in Touch

Discord: iskandarsulaili


Important

Introduces AzureHandler for Azure AI Foundry and OpenAI services with authentication, model registry, error handling, and UI integration.

  • Azure Provider:
    • Implements AzureHandler in azure.ts for Azure AI Foundry and Azure OpenAI services.
    • Supports API key and AAD authentication.
    • Handles all current and future GPT-5 variants.
    • Normalizes Azure-specific errors.
    • Integrates with Roo Code provider registry and model picker UI.
  • UI:
    • ModelPicker.tsx allows model selection via dropdown or manual entry.
  • Testing:
    • Unit tests in azure.spec.ts for endpoints, authentication, model registry, and error handling.
  • Dependencies:
    • Adds @azure/identity to package.json.

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

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Nov 13, 2025
@roomote
Copy link
Contributor

roomote bot commented Nov 13, 2025

Rooviewer Clock   See task on Roo Cloud

Review completed. I've identified 3 issues that need attention:

  • Missing deasync dependency - Runtime error when AAD authentication is enabled (azure.ts:75)
  • Undefined azureScope property - Type contract violation in AzureProviderOptions (azure.ts:62)
  • Unsafe null handling - AAD token acquisition doesn't validate response before accessing .token (azure.ts:71)

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

options.azureClientSecret
)
// Azure OpenAI/Foundry resource scope
const scope = options.azureScope || "https://cognitiveservices.azure.com/.default"
Copy link
Contributor

Choose a reason for hiding this comment

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

The code uses options.azureScope but this property isn't defined in the AzureProviderOptions interface. Please add it for type safety.

.catch(e => { error = e })
const start = Date.now()
while (!token && !error && Date.now() - start < 10000) {
require("deasync").runLoopOnce()
Copy link
Contributor

Choose a reason for hiding this comment

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

The code uses require("deasync").runLoopOnce() for synchronous AAD token acquisition, but the deasync package is not declared in package.json dependencies. This will cause a runtime error when users enable AAD authentication (azureUseAAD: true). Add deasync to the dependencies or refactor to use an async initialization pattern.

Fix it with Roo Code or mention @roomote and request a fix.

options.azureClientSecret
)
// Azure OpenAI/Foundry resource scope
const scope = options.azureScope || "https://cognitiveservices.azure.com/.default"
Copy link
Contributor

Choose a reason for hiding this comment

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

The azureScope property is referenced here but is not defined in the AzureProviderOptions type (lines 13-28). This will cause TypeScript errors or unexpected runtime behavior if users try to override the scope. The property should be added to the type definition or removed from this line if the default scope is always intended.

Fix it with Roo Code or mention @roomote and request a fix.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Nov 13, 2025
let token: string | undefined
let error: any
credential.getToken(scope)
.then(res => { token = res?.token })
Copy link
Contributor

Choose a reason for hiding this comment

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

Unsafe null handling in AAD token acquisition. The promise handler .then(res => { token = res?.token }) doesn't validate that res is defined before accessing .token. If getToken() resolves with undefined (which can happen with certain credential configurations), this will set token to undefined, causing the timeout error on line 77 instead of a more accurate "Invalid token response" error. Consider: .then(res => { if (!res?.token) throw new Error('Invalid token response'); token = res.token }).

Fix it with Roo Code or mention @roomote and request a fix.

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

Labels

enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

2 participants