Skip to content

Adding connection_manager property to AgentApplication - #432

Merged
Rodrigo Brandão (rodrigobr-msft) merged 6 commits into
mainfrom
users/robrandao/app-connections
Jun 23, 2026
Merged

Adding connection_manager property to AgentApplication#432
Rodrigo Brandão (rodrigobr-msft) merged 6 commits into
mainfrom
users/robrandao/app-connections

Conversation

@rodrigobr-msft

Copy link
Copy Markdown
Contributor

This pull request strengthens the handling of the connection_manager and authorization parameters in the AgentApplication class 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:

  • Added a guard in the AgentApplication constructor to raise an error if both authorization and connection_manager are provided, preventing ambiguous application state.
  • Ensured that when authorization is provided, the connection_manager is always sourced from the authorization object.
  • Introduced a connection_manager property to the AgentApplication class for consistent and clear access to the connection manager. [1] [2]

Testing improvements:

  • Added tests to verify that providing both authorization and connection_manager raises an error, and that the connection_manager property returns the correct manager depending on how the application was instantiated.

Copilot AI review requested due to automatic review settings June 23, 2026 20:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 authorization and connection_manager.
  • Introduce AgentApplication.connection_manager property 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 valid Connections implementation happens to be falsy. Prefer connection_manager is None for 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>
Copilot AI review requested due to automatic review settings June 23, 2026 20:20
@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) marked this pull request as ready for review June 23, 2026 20:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 23, 2026 20:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

@axelsrz Axel Suárez (axelsrz) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

:shipit:

@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) merged commit 91f853d into main Jun 23, 2026
11 checks passed
@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) deleted the users/robrandao/app-connections branch June 23, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants