Skip to content

Adding SlackTurnContext, SlackActivity, and other ease-of-use improvements to the Slack extension - #624

Merged
Rodrigo Brandão (rodrigobr-msft) merged 11 commits into
mainfrom
users/robrandao/slack
Oct 13, 2026
Merged

Rodrigo Brandão (rodrigobr-msft) merged 11 commits into
mainfrom
users/robrandao/slack

Conversation

@rodrigobr-msft

Copy link
Copy Markdown
Contributor

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:

  • Introduced SlackTurnContext and SlackActivity classes 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]
  • Updated the public API to use message() and event() methods for registering Slack route handlers, replacing the older on_message() and on_event() methods, which are now deprecated but still available for backward compatibility. (microsoft_agents/hosting/slack/slack_agent_extension.py [1] [2] [3] [4]
  • Added a new protocol, 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.py libraries/microsoft-agents-hosting-slack/microsoft_agents/hosting/slack/route_handlers.pyR1-R49)

Resource Management and Initialization:

Type and Import Cleanups:

  • Updated type signatures and imports for clarity and future compatibility, including use of typing_extensions.deprecated and improved type annotations in slack_model.py. (microsoft_agents/hosting/slack/slack_agent_extension.py [1] microsoft_agents/hosting/slack/api/slack_model.py [2] [3]
  • Exposed new public symbols in the Slack module's __init__.py. (microsoft_agents/hosting/slack/__init__.py [1] [2]

Testing Improvements:

  • Updated and expanded tests to cover the new message() and event() 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.

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.

🟡 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.

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.

🟢 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.

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.

🟢 Approval recommended

The implementation is internally consistent, backward compatible, and covered by focused tests.

0 open findings

2 resolved since last review

🧠 Review effort: Balanced

@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) marked this pull request as ready for review October 13, 2026 16:27

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.

🟡 Changes recommended

Eager aiohttp session construction breaks synchronous initialization, and two unused imports fail Flake8.

3 open findings

🧠 Review effort: Balanced

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.

🟡 Changes recommended

The internally created reusable aiohttp session lacks lifecycle cleanup and can remain open at application shutdown.

1 open finding
3 resolved since last review

🧠 Review effort: Balanced

@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) merged commit 7dc0c29 into main Oct 13, 2026
11 checks passed
@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) deleted the users/robrandao/slack branch October 13, 2026 19:36
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.

Implement custom TurnContext for Slack extension

3 participants