Linter issues - #485
Closed
Rodrigo Brandão (rodrigobr-msft) wants to merge 4 commits into
Closed
Conversation
Copilot started reviewing on behalf of
Rodrigo Brandão (rodrigobr-msft)
July 22, 2026 01:04
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR primarily targets lint/type-check cleanliness across the Agents SDK Python packages, tightening type annotations, adding a few missing protocol members, and adjusting some runtime validation/response defaults in hosting-core and activity models.
Changes:
- Refactors typing/annotations and small runtime validations across hosting-core (turn context, adapters, OAuth handlers, proactive helpers, and application wiring).
- Adds/extends protocol surface area (e.g.,
close()on connector/user-token clients; stricterNotImplementedErrorstubs for protocol methods). - Introduces/uses new model utilities and channel-id helpers to normalize inputs and reduce
Nonehandling issues.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/turn_context.py | Typing cleanup, plugin handler list typing, _emit refactor, and trace activity construction via pick_model. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/rest_channel_service_client_factory.py | Improves agentic token acquisition by validating tenant ID once and reusing it. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/message_factory.py | Refactors attachment helpers and input_hint typing/handling. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/http/_http_adapter_base.py | Adds HTTPStatus usage and defensive handling when invoke responses are absent. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/connector/user_token_client_base.py | Extends protocol to require an async close() method. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/connector/connector_client_base.py | Extends protocol to require an async close() method. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/client/channels_configuration.py | Replaces pass with explicit NotImplementedError for protocol requirement clarity. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/client/channel_protocol.py | Makes response_body_type explicitly optional in the protocol signature. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/client/channel_host_protocol.py | Adds explicit protocol attributes for host/channel metadata. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/client/channel_factory_protocol.py | Replaces pass with explicit NotImplementedError for protocol clarity. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/channel_service_adapter.py | Tightens error types and type annotations for connector/user-token clients and invoke responses. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/channel_adapter.py | Type/annotation fixes and conversation creation activity field updates. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/streaming/streaming_response.py | Avoids runtime circular imports via TYPE_CHECKING and updates type hints. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/proactive/conversation.py | Improves typing of identity extraction from turn state. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/authorization.py | Minor robustness improvement for Teams channel detection. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_handlers/connector_user_authorization.py | Adjusts OBO exchange return behavior to consistently return a TokenResponse. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_handlers/agentic_user_authorization.py | Adds tenant-id validation and improved error logging/messages for agentic token retrieval. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_handlers/_user_authorization.py | Strengthens turn-state requirements with casts and explicit missing-state errors. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_handlers/_authorization_handler.py | Adds validation requiring settings when constructing the default handler. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/app_options.py | Removes stray whitespace and keeps options clean for linting. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/agent_application.py | Broad typing tweaks, storage wiring refactor, and deprecation marking for env parsing. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/_oauth/_oauth_flow.py | Adds validation for token-exchange prerequisites and aligns return types. |
| libraries/microsoft-agents-copilotstudio-client/microsoft_agents/copilotstudio/client/power_platform_environment.py | Fixes endpoint suffix lookup to raise on invalid cloud categories. |
| libraries/microsoft-agents-activity/microsoft_agents/activity/turn_context_protocol.py | Simplifies protocol typing by removing the generic parameterization. |
| libraries/microsoft-agents-activity/microsoft_agents/activity/token_response.py | Fixes exception handling/flow in is_exchangeable. |
| libraries/microsoft-agents-activity/microsoft_agents/activity/conversation_reference.py | Refactors docs/type-checking structure and imports; keeps runtime behavior focused. |
| libraries/microsoft-agents-activity/microsoft_agents/activity/conversation_parameters.py | Adds explicit conversation field and required import. |
| libraries/microsoft-agents-activity/microsoft_agents/activity/channels.py | Adds ChannelId normalization support for capability checks. |
| libraries/microsoft-agents-activity/microsoft_agents/activity/channel_id.py | Improves Optional typing and adds channel/sub-channel parsing helpers. |
| libraries/microsoft-agents-activity/microsoft_agents/activity/activity.py | Reduces docstring verbosity and adds TYPE_CHECKING init signature for better typing. |
| libraries/microsoft-agents-activity/microsoft_agents/activity/_model_utils.py | Improves generic typing for pick_model. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
10
to
14
| from contextlib import nullcontext | ||
| from copy import copy | ||
| from functools import partial | ||
| from warnings import deprecated | ||
|
|
Comment on lines
153
to
157
| self._turn_state_factory = ( | ||
| options.turn_state_factory | ||
| or kwargs.get("turn_state_factory", None) | ||
| or partial(TurnState.with_storage, self._options.storage) | ||
| or partial(StateT.with_storage, self._storage) | ||
| ) |
Comment on lines
+155
to
161
| if not input_hint: | ||
| return attachment_activity( | ||
| AttachmentLayoutTypes.list, attachments, text, speak | ||
| ) | ||
| return attachment_activity( | ||
| AttachmentLayoutTypes.list, attachments, text, speak, input_hint | ||
| ) |
Comment on lines
+191
to
197
| if not input_hint: | ||
| return attachment_activity( | ||
| AttachmentLayoutTypes.carousel, attachments, text, speak | ||
| ) | ||
| return attachment_activity( | ||
| AttachmentLayoutTypes.carousel, attachments, text, speak, input_hint | ||
| ) |
Comment on lines
102
to
106
| return ( | ||
| button_cnt <= max_actions[channel_id] | ||
| button_count <= max_actions[channel] | ||
| if channel_id in max_actions | ||
| else False | ||
| ) |
Comment on lines
+333
to
335
| handlers = list(plugins) | ||
|
|
||
| async def emit_next(i: int): |
Comment on lines
+70
to
76
| identity: Optional[ClaimsIdentity] = cast( | ||
| ClaimsIdentity | None, | ||
| context.turn_state.get( | ||
| ChannelAdapter.AGENT_IDENTITY_KEY | ||
| )) | ||
|
|
||
| reference = context.activity.get_conversation_reference() |
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.
No description provided.