From b757ab3eff60169b039359381f34949e9f911e92 Mon Sep 17 00:00:00 2001 From: kylerohn-msft Date: Thu, 9 Jul 2026 13:40:20 -0700 Subject: [PATCH 1/2] remove reduntant load --- .../hosting/core/app/agent_application.py | 49 ++++++++++++------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/agent_application.py b/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/agent_application.py index 2ce8e082..bdcc641a 100644 --- a/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/agent_application.py +++ b/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/agent_application.py @@ -127,9 +127,11 @@ def __init__( "ApplicationOptions.storage is required and was not configured.", stack_info=True, ) - raise ApplicationError(""" + raise ApplicationError( + """ The `ApplicationOptions.storage` property is required and was not configured. - """) + """ + ) if options.long_running_messages and ( not options.adapter or not options.bot_app_id @@ -138,10 +140,12 @@ def __init__( "ApplicationOptions.long_running_messages requires an adapter and bot_app_id.", stack_info=True, ) - raise ApplicationError(""" + raise ApplicationError( + """ The `ApplicationOptions.long_running_messages` property is unavailable because no adapter or `bot_app_id` was configured. - """) + """ + ) if options.adapter: self._adapter = options.adapter @@ -217,10 +221,12 @@ def adapter(self) -> ChannelServiceAdapter: "AgentApplication.adapter(): self._adapter is not configured.", stack_info=True, ) - raise ApplicationError(""" + raise ApplicationError( + """ The AgentApplication.adapter property is unavailable because it was not configured when creating the AgentApplication. - """) + """ + ) return self._adapter @@ -238,10 +244,12 @@ def auth(self) -> Authorization: "AgentApplication.auth(): self._auth is not configured.", stack_info=True, ) - raise ApplicationError(""" + raise ApplicationError( + """ The `AgentApplication.auth` property is unavailable because no Auth options were configured. - """) + """ + ) return self._auth @@ -269,10 +277,12 @@ def proactive(self) -> Proactive: "AgentApplication.proactive(): proactive options are not configured.", stack_info=True, ) - raise ApplicationError(""" + raise ApplicationError( + """ The `AgentApplication.proactive` property is unavailable because no ProactiveOptions were configured in ApplicationOptions. - """) + """ + ) return self._proactive def before_turn( @@ -618,7 +628,8 @@ def handoff( *, auth_handlers: Optional[list[str]] = None, **kwargs, - ) -> Callable[[TurnContext, StateT, str], Awaitable[None]]: ... + ) -> Callable[[TurnContext, StateT, str], Awaitable[None]]: + ... @overload def handoff( @@ -629,7 +640,8 @@ def handoff( ) -> Callable[ [Callable[[TurnContext, StateT, str], Awaitable[None]]], Callable[[TurnContext, StateT, str], Awaitable[None]], - ]: ... + ]: + ... def handoff( self, @@ -724,10 +736,12 @@ async def sign_in_success(context: TurnContext, state: TurnState, connection_id: f"Failed to register sign-in success handler for route handler {func.__name__}", stack_info=True, ) - raise ApplicationError(""" + raise ApplicationError( + """ The `AgentApplication.on_sign_in_success` method is unavailable because no Auth options were configured. - """) + """ + ) return func def on_sign_in_failure( @@ -758,10 +772,12 @@ async def sign_in_failure(context: TurnContext, state: TurnState, connection_id: f"Failed to register sign-in failure handler for route handler {func.__name__}", stack_info=True, ) - raise ApplicationError(""" + raise ApplicationError( + """ The `AgentApplication.on_sign_in_failure` method is unavailable because no Auth options were configured. - """) + """ + ) return func def error( @@ -915,7 +931,6 @@ async def _initialize_state(self, context: TurnContext) -> StateT: else: logger.debug("Using default turn state factory") turn_state = TurnState.with_storage(self._options.storage) - await turn_state.load(context, self._options.storage) turn_state = cast(StateT, turn_state) From a30c752a14a567092ccb2b3f82b1b3373dc6f357 Mon Sep 17 00:00:00 2001 From: kylerohn-msft Date: Thu, 9 Jul 2026 13:45:07 -0700 Subject: [PATCH 2/2] fix formatting --- .../hosting/core/app/agent_application.py | 48 +++++++------------ 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/agent_application.py b/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/agent_application.py index bdcc641a..f6f0b7e9 100644 --- a/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/agent_application.py +++ b/libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/agent_application.py @@ -127,11 +127,9 @@ def __init__( "ApplicationOptions.storage is required and was not configured.", stack_info=True, ) - raise ApplicationError( - """ + raise ApplicationError(""" The `ApplicationOptions.storage` property is required and was not configured. - """ - ) + """) if options.long_running_messages and ( not options.adapter or not options.bot_app_id @@ -140,12 +138,10 @@ def __init__( "ApplicationOptions.long_running_messages requires an adapter and bot_app_id.", stack_info=True, ) - raise ApplicationError( - """ + raise ApplicationError(""" The `ApplicationOptions.long_running_messages` property is unavailable because no adapter or `bot_app_id` was configured. - """ - ) + """) if options.adapter: self._adapter = options.adapter @@ -221,12 +217,10 @@ def adapter(self) -> ChannelServiceAdapter: "AgentApplication.adapter(): self._adapter is not configured.", stack_info=True, ) - raise ApplicationError( - """ + raise ApplicationError(""" The AgentApplication.adapter property is unavailable because it was not configured when creating the AgentApplication. - """ - ) + """) return self._adapter @@ -244,12 +238,10 @@ def auth(self) -> Authorization: "AgentApplication.auth(): self._auth is not configured.", stack_info=True, ) - raise ApplicationError( - """ + raise ApplicationError(""" The `AgentApplication.auth` property is unavailable because no Auth options were configured. - """ - ) + """) return self._auth @@ -277,12 +269,10 @@ def proactive(self) -> Proactive: "AgentApplication.proactive(): proactive options are not configured.", stack_info=True, ) - raise ApplicationError( - """ + raise ApplicationError(""" The `AgentApplication.proactive` property is unavailable because no ProactiveOptions were configured in ApplicationOptions. - """ - ) + """) return self._proactive def before_turn( @@ -628,8 +618,7 @@ def handoff( *, auth_handlers: Optional[list[str]] = None, **kwargs, - ) -> Callable[[TurnContext, StateT, str], Awaitable[None]]: - ... + ) -> Callable[[TurnContext, StateT, str], Awaitable[None]]: ... @overload def handoff( @@ -640,8 +629,7 @@ def handoff( ) -> Callable[ [Callable[[TurnContext, StateT, str], Awaitable[None]]], Callable[[TurnContext, StateT, str], Awaitable[None]], - ]: - ... + ]: ... def handoff( self, @@ -736,12 +724,10 @@ async def sign_in_success(context: TurnContext, state: TurnState, connection_id: f"Failed to register sign-in success handler for route handler {func.__name__}", stack_info=True, ) - raise ApplicationError( - """ + raise ApplicationError(""" The `AgentApplication.on_sign_in_success` method is unavailable because no Auth options were configured. - """ - ) + """) return func def on_sign_in_failure( @@ -772,12 +758,10 @@ async def sign_in_failure(context: TurnContext, state: TurnState, connection_id: f"Failed to register sign-in failure handler for route handler {func.__name__}", stack_info=True, ) - raise ApplicationError( - """ + raise ApplicationError(""" The `AgentApplication.on_sign_in_failure` method is unavailable because no Auth options were configured. - """ - ) + """) return func def error(