fix: update custom token provider functions for copilot review#867
Merged
Conversation
…e OpenAI integration
Contributor
Coverage Report •
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors Azure OpenAI authentication setup to reduce duplication by passing the Azure credential object directly into OpenAIChatCompletionClient, and it slightly broadens a system-prompt leakage detection regex to better recognize hyphenated agent names.
Changes:
- Replace per-request
get_token()callables with directself._credentialusage when creatingOpenAIChatCompletionClient(orchestrator + title service). - Remove the unused
TOKEN_ENDPOINTconstant fromtitle_service.py. - Update system-prompt leakage detection patterns to better match hyphenated agent handoff strings.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/backend/services/title_service.py |
Simplifies title service client initialization by passing the Azure credential directly and removing the unused token endpoint constant. |
src/backend/orchestrator.py |
Simplifies chat client credential wiring in both Foundry and Direct modes; expands handoff leakage regex to match hyphenated agent names. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ed agent names and initialize wiring in TitleService
Avijit-Microsoft
approved these changes
Jun 5, 2026
Contributor
|
🎉 This PR is included in version 2.7.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
This pull request simplifies authentication handling for Azure OpenAI clients by removing custom token provider functions and passing the credential object directly. It also includes a minor update to a regular expression for improved agent handoff detection.
Authentication handling improvements:
get_tokenprovider functions with direct use ofself._credentialwhen initializingOpenAIChatCompletionClientin bothorchestrator.pyandtitle_service.py, reducing code duplication and improving maintainability.TOKEN_ENDPOINTconstant fromtitle_service.py.Regex update:
_check_input_for_harmful_contentto better match agent names containing hyphens, improving pattern coverage.Does this introduce a breaking change?
Golden Path Validation
Deployment Validation
Other Information
This pull request refactors how Azure OpenAI authentication credentials are provided to the chat client across the codebase. The main change is to pass the credential object directly instead of a token-providing function, simplifying authentication logic and reducing code duplication. Additionally, an unused constant is removed, and some regular expressions are slightly adjusted.
Azure OpenAI Authentication Refactor:
get_tokenfunctions with direct passing of the credential object (self._credential) toOpenAIChatCompletionClientin both orchestrator and title service modules. This simplifies the authentication flow and reduces redundant code.TOKEN_ENDPOINTconstant fromsrc/backend/services/title_service.pyas it is no longer needed after refactoring.Regular Expression Update:
_check_input_for_harmful_contentto better match agent handoff instructions by expanding the character class for agent names.