Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 18, 2026

Related GitHub Issue

Closes: #10782

Description

This PR attempts to address Issue #10782 by fixing Azure Foundry compatibility with the OpenAI Native handler.

Azure Foundry/AI does not support the prompt_cache_retention parameter that OpenAI's API accepts. When users configure the OpenAI Native handler with an Azure Foundry endpoint (e.g., *.openai.azure.com or *.services.ai.azure.com), API calls would fail because Azure rejects this unsupported parameter.

Implementation Details:

  • Added isAzureEndpoint() helper method to detect Azure base URLs
  • Modified getPromptCacheRetention() to return undefined for Azure endpoints, effectively skipping the parameter in API requests
  • Handles common Azure URL patterns: *.azure.com and *.azure-api.net

Test Procedure

  • Added 5 new unit tests to verify the Azure endpoint detection:
    • Azure .azure.com endpoints skip prompt_cache_retention
    • Azure AI Foundry *.services.ai.azure.com endpoints skip prompt_cache_retention
    • Azure API Management *.azure-api.net endpoints skip prompt_cache_retention
    • Non-Azure endpoints still include prompt_cache_retention for eligible models
    • Default OpenAI endpoints (no base URL configured) include prompt_cache_retention

To run tests: cd src && npx vitest run api/providers/__tests__/openai-native-usage.spec.ts

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.

Documentation Updates

  • No documentation updates are required.

Additional Notes

Feedback and guidance are welcome! This is an attempt to help users who are locked to Azure Foundry endpoints in their work tenants.


Important

Fixes Azure endpoint compatibility by skipping unsupported prompt_cache_retention parameter in OpenAiNativeHandler.

  • Behavior:
    • getPromptCacheRetention() in openai-native.ts now returns undefined for Azure endpoints, skipping prompt_cache_retention in requests.
    • isAzureEndpoint() added to detect Azure URLs (*.azure.com, *.azure-api.net).
  • Tests:
    • Added 5 unit tests in openai-native-usage.spec.ts to verify Azure endpoint detection and parameter omission.
    • Tests cover Azure .azure.com, *.services.ai.azure.com, and *.azure-api.net endpoints, as well as non-Azure and default OpenAI endpoints.

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

Azure Foundry/AI does not support the prompt_cache_retention parameter
that OpenAI API accepts. This causes API errors when users try to use
models like gpt-5.2-codex through Azure Foundry endpoints.

This fix adds Azure endpoint detection and skips the prompt_cache_retention
parameter when the configured base URL points to an Azure endpoint
(*.azure.com or *.azure-api.net).

Fixes #10782
@roomote
Copy link
Contributor Author

roomote bot commented Jan 18, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The implementation correctly detects Azure endpoints and skips the unsupported prompt_cache_retention parameter. The Azure detection logic handles edge cases properly (invalid URLs, case sensitivity) and is consistent with existing Azure patterns in the codebase. Test coverage is comprehensive.

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

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

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Azure provider to support Azure Foundry

2 participants