Repository navigation
Adding SlackTurnContext, SlackActivity, and other ease-of-use improvements to the Slack extension - #624
Merged
Conversation
…into users/robrandao/slack
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The context wrapper can lose buffered expect-replies responses, and the new wrapper behavior needs direct testing.
4 open findings
What changed in this PR
Modernizes Slack route handling with typed Slack contexts, activities, and API registration.
Changes:
- Adds
SlackTurnContext,SlackActivity, and typed route wrappers. - Introduces
message()/event()while deprecating legacy aliases. - Expands API typing and route-registration tests.
| File | Description |
|---|---|
slack_turn_context.py |
Adds Slack-specific context and client access. |
slack_activity.py |
Adds typed Slack channel-data access. |
route_handlers.py |
Wraps Slack route handlers with typed contexts. |
slack_agent_extension.py |
Modernizes routes and binds SlackApi. |
api/slack_model.py |
Refines get() typing. |
api/slack_api.py |
Documents session lifecycle limitations. |
__init__.py |
Exports new public types. |
test_slack_agent_extension.py |
Tests modern and deprecated route APIs. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The implementation is consistent with existing extension patterns and is adequately tested and documented.
2 open findings
2 resolved since last review
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
Rodrigo Brandão (rodrigobr-msft)
marked this pull request as ready for review
October 13, 2026 16:27
Rodrigo Brandão (rodrigobr-msft)
requested a review
from a team
as a code owner
October 13, 2026 16:27
tracyboehrer (tracyboehrer)
approved these changes
Oct 13, 2026
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 introduces significant improvements to the Slack integration in the Microsoft Agents Hosting library. The changes modernize and clarify the route handler API, introduce Slack-specific context and activity types, and improve resource management patterns. Deprecated APIs are now clearly marked, and new tests ensure the updated behavior.
API Modernization and Slack Context Enhancements:
SlackTurnContextandSlackActivityclasses to provide Slack-specific accessors and context for route handlers, ensuring handlers receive typed objects with Slack extensions. (microsoft_agents/hosting/slack/slack_turn_context.py[1]microsoft_agents/hosting/slack/slack_activity.py[2]message()andevent()methods for registering Slack route handlers, replacing the olderon_message()andon_event()methods, which are now deprecated but still available for backward compatibility. (microsoft_agents/hosting/slack/slack_agent_extension.py[1] [2] [3] [4]SlackRouteHandler, and a helper function,wrap_slack_route_handler, to ensure Slack-specific context is passed to route handlers, while maintaining compatibility with the core routing engine. (microsoft_agents/hosting/slack/route_handlers.pylibraries/microsoft-agents-hosting-slack/microsoft_agents/hosting/slack/route_handlers.pyR1-R49)Resource Management and Initialization:
before_turnhook inSlackAgentExtensionto bind a per-turnSlackApiinstance, improving resource management and aligning with future managed-resource patterns. (microsoft_agents/hosting/slack/slack_agent_extension.pylibraries/microsoft-agents-hosting-slack/microsoft_agents/hosting/slack/slack_agent_extension.pyR81-R95)SlackApiabout improving the lifecycle management ofaiohttp.ClientSessionfor future refactoring. (microsoft_agents/hosting/slack/api/slack_api.pylibraries/microsoft-agents-hosting-slack/microsoft_agents/hosting/slack/api/slack_api.pyR98-R103)Type and Import Cleanups:
typing_extensions.deprecatedand improved type annotations inslack_model.py. (microsoft_agents/hosting/slack/slack_agent_extension.py[1]microsoft_agents/hosting/slack/api/slack_model.py[2] [3]__init__.py. (microsoft_agents/hosting/slack/__init__.py[1] [2]Testing Improvements:
message()andevent()APIs, renamed test classes for clarity, and added tests to verify deprecation warnings and delegation of deprecated methods. (tests/hosting_slack/test_slack_agent_extension.py[1] [2] [3] [4] [5]These changes collectively make the Slack integration more robust, extensible, and easier to use for developers building Slack-enabled agents.