You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pull request introduces significant performance improvements and dependency updates for the Teams API client, along with supporting changes to resource cleanup and development setup. The most important changes are summarized below.
Teams API Client Performance and Resource Management:
Added caching of the SSL context in _teams_api_client.py to avoid repeated CA certificate loading and reduce client initialization overhead, significantly improving performance for high-traffic agents.
Refactored Teams API client construction to use a shared _client function that leverages the cached SSL context. [1][2]
Added an on_after_turn hook to ensure the Teams API client's HTTP resources are properly closed after each turn, preventing resource leaks.
Dependency Updates:
Updated the microsoft-teams-api dependency to version 2.1.0 in both setup.py and the changelog. [1][2]
Development and Test Setup:
Ensured the microsoft-agents-hosting-msteams package is installed in editable mode in both development setup scripts (dev_setup.sh and dev_setup.ps1). [1][2]
Adjusted test helper to no longer pre-cache the ApiClient in the test context, aligning with the new client lifecycle.
Constructing the cached context directly from certifi drops HTTPX's default SSL_CERT_FILE/SSL_CERT_DIR handling. Deployments that add a corporate or private CA through those standard environment variables will start failing TLS verification. Build the cached context with the same trust-environment semantics as HTTPX's default instead of hard-coding only the certifi bundle.
The caching behavior that provides this PR's performance improvement is not asserted by the tests: the existing boundary test creates one client and would still pass if a fresh SSL context were built for every client. Add a test that creates multiple clients (or calls this helper repeatedly) while spying on ssl.create_default_context, and assert that context creation occurs only once.
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
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 introduces significant performance improvements and dependency updates for the Teams API client, along with supporting changes to resource cleanup and development setup. The most important changes are summarized below.
Teams API Client Performance and Resource Management:
_teams_api_client.pyto avoid repeated CA certificate loading and reduce client initialization overhead, significantly improving performance for high-traffic agents._clientfunction that leverages the cached SSL context. [1] [2]on_after_turnhook to ensure the Teams API client's HTTP resources are properly closed after each turn, preventing resource leaks.Dependency Updates:
microsoft-teams-apidependency to version 2.1.0 in bothsetup.pyand the changelog. [1] [2]Development and Test Setup:
microsoft-agents-hosting-msteamspackage is installed in editable mode in both development setup scripts (dev_setup.shanddev_setup.ps1). [1] [2]ApiClientin the test context, aligning with the new client lifecycle.