microsoft-agents-hosting-core 0.5.0.dev17__py3-none-any.whl → 0.5.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -93,7 +93,6 @@ class AgentApplication(Agent, Generic[StateT]):
93
93
  :param kwargs: Additional configuration parameters.
94
94
  :type kwargs: Any
95
95
  """
96
- self.typing = TypingIndicator()
97
96
  self._route_list = _RouteList[StateT]()
98
97
 
99
98
  configuration = kwargs
@@ -659,9 +658,12 @@ class AgentApplication(Agent, Generic[StateT]):
659
658
  await self._start_long_running_call(context, self._on_turn)
660
659
 
661
660
  async def _on_turn(self, context: TurnContext):
661
+ typing = None
662
662
  try:
663
663
  if context.activity.type != ActivityTypes.typing:
664
- await self._start_typing(context)
664
+ if self._options.start_typing_timer:
665
+ typing = TypingIndicator()
666
+ await typing.start(context)
665
667
 
666
668
  self._remove_mentions(context)
667
669
 
@@ -709,11 +711,8 @@ class AgentApplication(Agent, Generic[StateT]):
709
711
  )
710
712
  await self._on_error(context, err)
711
713
  finally:
712
- self.typing.stop()
713
-
714
- async def _start_typing(self, context: TurnContext):
715
- if self._options.start_typing_timer:
716
- await self.typing.start(context)
714
+ if typing:
715
+ await typing.stop()
717
716
 
718
717
  def _remove_mentions(self, context: TurnContext):
719
718
  if (
@@ -4,9 +4,9 @@ Licensed under the MIT License.
4
4
  """
5
5
 
6
6
  from __future__ import annotations
7
+ import asyncio
7
8
  import logging
8
9
 
9
- from threading import Timer
10
10
  from typing import Optional
11
11
 
12
12
  from microsoft_agents.hosting.core import TurnContext
@@ -20,36 +20,59 @@ class TypingIndicator:
20
20
  Encapsulates the logic for sending "typing" activity to the user.
21
21
  """
22
22
 
23
- _interval: int
24
- _timer: Optional[Timer] = None
25
-
26
- def __init__(self, interval=1000) -> None:
27
- self._interval = interval
23
+ def __init__(self, intervalSeconds=1) -> None:
24
+ self._intervalSeconds = intervalSeconds
25
+ self._task: Optional[asyncio.Task] = None
26
+ self._running: bool = False
27
+ self._lock = asyncio.Lock()
28
28
 
29
29
  async def start(self, context: TurnContext) -> None:
30
- if self._timer is not None:
31
- return
30
+ async with self._lock:
31
+ if self._running:
32
+ return
33
+
34
+ logger.debug(
35
+ f"Starting typing indicator with interval: {self._intervalSeconds} seconds"
36
+ )
37
+ self._running = True
38
+ self._task = asyncio.create_task(self._typing_loop(context))
32
39
 
33
- logger.debug(f"Starting typing indicator with interval: {self._interval} ms")
34
- func = self._on_timer(context)
35
- self._timer = Timer(self._interval, func)
36
- self._timer.start()
37
- await func()
40
+ async def stop(self) -> None:
41
+ async with self._lock:
42
+ if not self._running:
43
+ return
38
44
 
39
- def stop(self) -> None:
40
- if self._timer:
41
45
  logger.debug("Stopping typing indicator")
42
- self._timer.cancel()
43
- self._timer = None
46
+ self._running = False
47
+ task = self._task
48
+ self._task = None
44
49
 
45
- def _on_timer(self, context: TurnContext):
46
- async def __call__():
50
+ # Cancel outside the lock to avoid blocking
51
+ if task and not task.done():
52
+ task.cancel()
47
53
  try:
48
- logger.debug("Sending typing activity")
49
- await context.send_activity(Activity(type=ActivityTypes.typing))
50
- except Exception as e:
51
- # TODO: Improve when adding logging
52
- logger.error(f"Error sending typing activity: {e}")
53
- self.stop()
54
-
55
- return __call__
54
+ await task
55
+ except asyncio.CancelledError:
56
+ pass
57
+
58
+ async def _typing_loop(self, context: TurnContext):
59
+ """Continuously send typing indicators at the specified interval."""
60
+ try:
61
+ while True:
62
+ # Check running status under lock
63
+ async with self._lock:
64
+ if not self._running:
65
+ break
66
+
67
+ try:
68
+ logger.debug("Sending typing activity")
69
+ await context.send_activity(Activity(type=ActivityTypes.typing))
70
+ except Exception as e:
71
+ logger.error(f"Error sending typing activity: {e}")
72
+ async with self._lock:
73
+ self._running = False
74
+ break
75
+
76
+ await asyncio.sleep(self._intervalSeconds)
77
+ except asyncio.CancelledError:
78
+ logger.debug("Typing indicator loop cancelled")
@@ -124,7 +124,7 @@ class ConversationsOperations(ConversationsBase):
124
124
 
125
125
  def __init__(self, client: ClientSession, **kwargs):
126
126
  self.client = client
127
- self._max_conversation_id_length = kwargs.get("max_conversation_id_length", 200)
127
+ self._max_conversation_id_length = kwargs.get("max_conversation_id_length", 150)
128
128
 
129
129
  def _normalize_conversation_id(self, conversation_id: str) -> str:
130
130
  return conversation_id[: self._max_conversation_id_length]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: microsoft-agents-hosting-core
3
- Version: 0.5.0.dev17
3
+ Version: 0.5.1
4
4
  Summary: Core library for Microsoft Agents
5
5
  Author: Microsoft Corporation
6
6
  License-Expression: MIT
@@ -15,7 +15,7 @@ Classifier: Operating System :: OS Independent
15
15
  Requires-Python: >=3.10
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
- Requires-Dist: microsoft-agents-activity==0.5.0.dev17
18
+ Requires-Dist: microsoft-agents-activity==0.5.1
19
19
  Requires-Dist: pyjwt>=2.10.1
20
20
  Requires-Dist: isodate>=0.6.1
21
21
  Requires-Dist: azure-core>=1.30.0
@@ -34,6 +34,24 @@ This is the heart of the Microsoft 365 Agents SDK - think of it as the engine th
34
34
  # What is this?
35
35
  This library is part of the **Microsoft 365 Agents SDK for Python** - a comprehensive framework for building enterprise-grade conversational AI agents. The SDK enables developers to create intelligent agents that work across multiple platforms including Microsoft Teams, M365 Copilot, Copilot Studio, and web chat, with support for third-party integrations like Slack, Facebook Messenger, and Twilio.
36
36
 
37
+ ## Release Notes
38
+ <table style="width:100%">
39
+ <tr>
40
+ <th style="width:20%">Version</th>
41
+ <th style="width:20%">Date</th>
42
+ <th style="width:60%">Release Notes</th>
43
+ </tr>
44
+ <tr>
45
+ <td>0.5.0</td>
46
+ <td>2025-10-22</td>
47
+ <td>
48
+ <a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md">
49
+ 0.5.0 Release Notes
50
+ </a>
51
+ </td>
52
+ </tr>
53
+ </table>
54
+
37
55
  ## Packages Overview
38
56
 
39
57
  We offer the following PyPI packages to create conversational experiences based on Agents:
@@ -16,12 +16,12 @@ microsoft_agents/hosting/core/_oauth/_flow_storage_client.py,sha256=1MLD8m_qw0jS
16
16
  microsoft_agents/hosting/core/_oauth/_oauth_flow.py,sha256=vgg_sQLYr83YA0F7aQ1K5j8vEATw7ZS151ODkpCGYAM,12211
17
17
  microsoft_agents/hosting/core/app/__init__.py,sha256=GZQdog7BBMA8uD9iaRMNeRJf12rJZB3bAKFAD8Y8dVo,1228
18
18
  microsoft_agents/hosting/core/app/_type_defs.py,sha256=b5VZFWnQ5ONUZMtFxw7Q-mbbxIUSJ7RXcCXjqdHwSQw,438
19
- microsoft_agents/hosting/core/app/agent_application.py,sha256=M1ex1XCb3RNijJOSaJMTLajR9GrXqx8nim8Bp1yKLDU,31600
19
+ microsoft_agents/hosting/core/app/agent_application.py,sha256=yYAVFkn4VWO5ZzrXdGFR4UheYMD5xP28HCxWPeJz8wA,31560
20
20
  microsoft_agents/hosting/core/app/app_error.py,sha256=JgYBgv2EKe9Q2TFi5FeG_RneulBEa5SyBpWSF-duBzE,301
21
21
  microsoft_agents/hosting/core/app/app_options.py,sha256=P3XTFFuQCnEcHixfdmr5RPG-Wli4c1VSmCMRKVBBLsw,2792
22
22
  microsoft_agents/hosting/core/app/input_file.py,sha256=AEzVAnAPO1V7MWDI_uoZfcYY8Oog3XgvEpAeO-tATeY,1546
23
23
  microsoft_agents/hosting/core/app/query.py,sha256=lToDWFG7exUyPC5zxvna89013fDPKrUGOI8jyWFoUYk,328
24
- microsoft_agents/hosting/core/app/typing_indicator.py,sha256=CxLtgDTr6a8ELqUujHMvAh_CYpm3mwhomH-tfTQGSe8,1558
24
+ microsoft_agents/hosting/core/app/typing_indicator.py,sha256=L4zEqDHeu_0JmpDQwaB-j84TFLYzUAH0-tFUEfOxD0g,2442
25
25
  microsoft_agents/hosting/core/app/_routes/__init__.py,sha256=faz05Hk5Z1IGIXUwXljohym0lzE8nW3CbTpXlE-VcB0,300
26
26
  microsoft_agents/hosting/core/app/_routes/_route.py,sha256=gs5XVi74H1wzDShpZd9ZXVDrREjricFYVPz10XrK06c,2669
27
27
  microsoft_agents/hosting/core/app/_routes/_route_list.py,sha256=fe1-wmFaJJqYkWFcbNhJ9OMH954TneQR0-uoxyKQVlU,874
@@ -72,7 +72,7 @@ microsoft_agents/hosting/core/connector/get_product_info.py,sha256=SDxPqBCzzQLEU
72
72
  microsoft_agents/hosting/core/connector/user_token_base.py,sha256=h_l5D1SghN2RrUkFcKWQhCHlO9r7akMbzsm2x8MvomI,3639
73
73
  microsoft_agents/hosting/core/connector/user_token_client_base.py,sha256=dfUTUsBNOzWze9_JldAeLe73sydSDzlKyMKMvj48g2E,471
74
74
  microsoft_agents/hosting/core/connector/client/__init__.py,sha256=6JdKhmm7btmo0omxMBd8PJbtGFk0cnMwVUoStyW7Ft0,143
75
- microsoft_agents/hosting/core/connector/client/connector_client.py,sha256=UsvQrWROhrFQxyBu6TY9ej3wUS__VpcdpNZG8fu4-Tc,23398
75
+ microsoft_agents/hosting/core/connector/client/connector_client.py,sha256=nnKlXw98lB_eoTYMaHKc7PtxSKW3G6jUxCPFe4pdjSI,23398
76
76
  microsoft_agents/hosting/core/connector/client/user_token_client.py,sha256=1ey1mqV7pkC94Xl36PVrx5TOyumJQbpscbm2W9uvpHs,10609
77
77
  microsoft_agents/hosting/core/connector/teams/__init__.py,sha256=3ZMPGYyZ15EwvfQzfJJQy1J58oIt4InSxibl3BN6R54,100
78
78
  microsoft_agents/hosting/core/connector/teams/teams_connector_client.py,sha256=XGQDTYHrA_I9n9JlxGST5eesjsFhz2dnSaMSuyoFnKU,12676
@@ -91,8 +91,8 @@ microsoft_agents/hosting/core/storage/transcript_info.py,sha256=5VN32j99tshChAff
91
91
  microsoft_agents/hosting/core/storage/transcript_logger.py,sha256=_atDk3CJ05fIVMhlWGNa91IiM9bGLmOhasFko8Lxjhk,8237
92
92
  microsoft_agents/hosting/core/storage/transcript_memory_store.py,sha256=v1Ud9LSs8m5c9_Fa8i49SuAjw80dX1hDciqbRduDEOE,6444
93
93
  microsoft_agents/hosting/core/storage/transcript_store.py,sha256=ka74o0WvI5GhMZcFqSxVdamBhGzZcDZe6VNkG-sMy74,1944
94
- microsoft_agents_hosting_core-0.5.0.dev17.dist-info/licenses/LICENSE,sha256=ws_MuBL-SCEBqPBFl9_FqZkaaydIJmxHrJG2parhU4M,1141
95
- microsoft_agents_hosting_core-0.5.0.dev17.dist-info/METADATA,sha256=uZU4P_eK-dl83va49VTZJmqxj8ujFr9GJjeUMVzPRIY,8852
96
- microsoft_agents_hosting_core-0.5.0.dev17.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
97
- microsoft_agents_hosting_core-0.5.0.dev17.dist-info/top_level.txt,sha256=lWKcT4v6fTA_NgsuHdNvuMjSrkiBMXohn64ApY7Xi8A,17
98
- microsoft_agents_hosting_core-0.5.0.dev17.dist-info/RECORD,,
94
+ microsoft_agents_hosting_core-0.5.1.dist-info/licenses/LICENSE,sha256=ws_MuBL-SCEBqPBFl9_FqZkaaydIJmxHrJG2parhU4M,1141
95
+ microsoft_agents_hosting_core-0.5.1.dist-info/METADATA,sha256=merbpIwQI_ugRRiYfb75dt59uC65x7xx-UmQ32Gp8-4,9232
96
+ microsoft_agents_hosting_core-0.5.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
97
+ microsoft_agents_hosting_core-0.5.1.dist-info/top_level.txt,sha256=lWKcT4v6fTA_NgsuHdNvuMjSrkiBMXohn64ApY7Xi8A,17
98
+ microsoft_agents_hosting_core-0.5.1.dist-info/RECORD,,