Adding connection_manager property to AgentApplication - #432
Merged
Rodrigo Brandão (rodrigobr-msft) merged 6 commits intoJun 23, 2026
Conversation
Copilot started reviewing on behalf of
Rodrigo Brandão (rodrigobr-msft)
June 23, 2026 20:17
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves AgentApplication initialization semantics by eliminating ambiguous authorization/connection manager configuration and exposing a consistent connection_manager accessor. It also adds unit tests to confirm the guard behavior and the new property’s returned value.
Changes:
- Add a constructor guard to reject providing both
authorizationandconnection_manager. - Introduce
AgentApplication.connection_managerproperty and persist the chosen manager on the instance. - Add tests covering the guard and property behavior for both construction paths.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/agent_application.py | Adds constructor guard and connection_manager property; wires _connection_manager during initialization. |
| tests/hosting_core/app/test_agent_application.py | Adds tests validating the guard and the connection_manager property behavior. |
Comments suppressed due to low confidence (1)
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/agent_application.py:178
- Similarly, the required-parameter check uses
if not connection_manager:. That will incorrectly raise if a validConnectionsimplementation happens to be falsy. Preferconnection_manager is Nonefor Optional checks.
self._auth = authorization
self._connection_manager = self._auth.connection_manager
else:
if not connection_manager:
logger.error(
"AgentApplication: connection_manager is required for Authorization.",
stack_info=True,
)
raise ApplicationError(
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Rodrigo Brandão (rodrigobr-msft)
marked this pull request as ready for review
June 23, 2026 20:20
Copilot started reviewing on behalf of
Rodrigo Brandão (rodrigobr-msft)
June 23, 2026 20:21
View session
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot started reviewing on behalf of
Rodrigo Brandão (rodrigobr-msft)
June 23, 2026 20:25
View session
…microsoft/Agents-for-python into users/robrandao/app-connections
Rodrigo Brandão (rodrigobr-msft)
deleted the
users/robrandao/app-connections
branch
June 23, 2026 21:07
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.
This pull request strengthens the handling of the
connection_managerandauthorizationparameters in theAgentApplicationclass to prevent ambiguous configurations and improve clarity. It introduces a new property for accessing the connection manager and adds tests to verify the correct behavior.Enhancements to AgentApplication initialization and configuration:
AgentApplicationconstructor to raise an error if bothauthorizationandconnection_managerare provided, preventing ambiguous application state.authorizationis provided, theconnection_manageris always sourced from the authorization object.connection_managerproperty to theAgentApplicationclass for consistent and clear access to the connection manager. [1] [2]Testing improvements:
authorizationandconnection_managerraises an error, and that theconnection_managerproperty returns the correct manager depending on how the application was instantiated.