ag2 0.9.7__py3-none-any.whl → 0.9.9__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.

Potentially problematic release.


This version of ag2 might be problematic. Click here for more details.

Files changed (236) hide show
  1. {ag2-0.9.7.dist-info → ag2-0.9.9.dist-info}/METADATA +102 -75
  2. ag2-0.9.9.dist-info/RECORD +387 -0
  3. autogen/__init__.py +1 -2
  4. autogen/_website/generate_api_references.py +4 -5
  5. autogen/_website/generate_mkdocs.py +9 -15
  6. autogen/_website/notebook_processor.py +13 -14
  7. autogen/_website/process_notebooks.py +10 -10
  8. autogen/_website/utils.py +5 -4
  9. autogen/agentchat/agent.py +13 -13
  10. autogen/agentchat/assistant_agent.py +7 -6
  11. autogen/agentchat/contrib/agent_eval/agent_eval.py +3 -3
  12. autogen/agentchat/contrib/agent_eval/critic_agent.py +3 -3
  13. autogen/agentchat/contrib/agent_eval/quantifier_agent.py +3 -3
  14. autogen/agentchat/contrib/agent_eval/subcritic_agent.py +3 -3
  15. autogen/agentchat/contrib/agent_optimizer.py +3 -3
  16. autogen/agentchat/contrib/capabilities/generate_images.py +11 -11
  17. autogen/agentchat/contrib/capabilities/teachability.py +15 -15
  18. autogen/agentchat/contrib/capabilities/transforms.py +17 -18
  19. autogen/agentchat/contrib/capabilities/transforms_util.py +5 -5
  20. autogen/agentchat/contrib/capabilities/vision_capability.py +4 -3
  21. autogen/agentchat/contrib/captainagent/agent_builder.py +30 -30
  22. autogen/agentchat/contrib/captainagent/captainagent.py +22 -21
  23. autogen/agentchat/contrib/captainagent/tool_retriever.py +2 -3
  24. autogen/agentchat/contrib/gpt_assistant_agent.py +9 -9
  25. autogen/agentchat/contrib/graph_rag/document.py +3 -3
  26. autogen/agentchat/contrib/graph_rag/falkor_graph_query_engine.py +3 -3
  27. autogen/agentchat/contrib/graph_rag/falkor_graph_rag_capability.py +6 -6
  28. autogen/agentchat/contrib/graph_rag/graph_query_engine.py +3 -3
  29. autogen/agentchat/contrib/graph_rag/neo4j_graph_query_engine.py +5 -11
  30. autogen/agentchat/contrib/graph_rag/neo4j_graph_rag_capability.py +6 -6
  31. autogen/agentchat/contrib/graph_rag/neo4j_native_graph_query_engine.py +7 -7
  32. autogen/agentchat/contrib/graph_rag/neo4j_native_graph_rag_capability.py +6 -6
  33. autogen/agentchat/contrib/img_utils.py +1 -1
  34. autogen/agentchat/contrib/llamaindex_conversable_agent.py +11 -11
  35. autogen/agentchat/contrib/llava_agent.py +18 -4
  36. autogen/agentchat/contrib/math_user_proxy_agent.py +11 -11
  37. autogen/agentchat/contrib/multimodal_conversable_agent.py +8 -8
  38. autogen/agentchat/contrib/qdrant_retrieve_user_proxy_agent.py +6 -5
  39. autogen/agentchat/contrib/rag/chromadb_query_engine.py +22 -26
  40. autogen/agentchat/contrib/rag/llamaindex_query_engine.py +14 -17
  41. autogen/agentchat/contrib/rag/mongodb_query_engine.py +27 -37
  42. autogen/agentchat/contrib/rag/query_engine.py +7 -5
  43. autogen/agentchat/contrib/retrieve_assistant_agent.py +5 -5
  44. autogen/agentchat/contrib/retrieve_user_proxy_agent.py +8 -7
  45. autogen/agentchat/contrib/society_of_mind_agent.py +15 -14
  46. autogen/agentchat/contrib/swarm_agent.py +76 -98
  47. autogen/agentchat/contrib/text_analyzer_agent.py +7 -7
  48. autogen/agentchat/contrib/vectordb/base.py +10 -18
  49. autogen/agentchat/contrib/vectordb/chromadb.py +2 -1
  50. autogen/agentchat/contrib/vectordb/couchbase.py +18 -20
  51. autogen/agentchat/contrib/vectordb/mongodb.py +6 -5
  52. autogen/agentchat/contrib/vectordb/pgvectordb.py +40 -41
  53. autogen/agentchat/contrib/vectordb/qdrant.py +5 -5
  54. autogen/agentchat/contrib/web_surfer.py +20 -19
  55. autogen/agentchat/conversable_agent.py +292 -290
  56. autogen/agentchat/group/context_str.py +1 -3
  57. autogen/agentchat/group/context_variables.py +15 -25
  58. autogen/agentchat/group/group_tool_executor.py +10 -10
  59. autogen/agentchat/group/group_utils.py +15 -15
  60. autogen/agentchat/group/guardrails.py +7 -7
  61. autogen/agentchat/group/handoffs.py +19 -36
  62. autogen/agentchat/group/multi_agent_chat.py +7 -7
  63. autogen/agentchat/group/on_condition.py +4 -7
  64. autogen/agentchat/group/on_context_condition.py +4 -7
  65. autogen/agentchat/group/patterns/auto.py +8 -7
  66. autogen/agentchat/group/patterns/manual.py +7 -6
  67. autogen/agentchat/group/patterns/pattern.py +13 -12
  68. autogen/agentchat/group/patterns/random.py +3 -3
  69. autogen/agentchat/group/patterns/round_robin.py +3 -3
  70. autogen/agentchat/group/reply_result.py +2 -4
  71. autogen/agentchat/group/speaker_selection_result.py +5 -5
  72. autogen/agentchat/group/targets/group_chat_target.py +7 -6
  73. autogen/agentchat/group/targets/group_manager_target.py +4 -4
  74. autogen/agentchat/group/targets/transition_target.py +2 -1
  75. autogen/agentchat/groupchat.py +60 -63
  76. autogen/agentchat/realtime/experimental/audio_adapters/twilio_audio_adapter.py +4 -4
  77. autogen/agentchat/realtime/experimental/audio_adapters/websocket_audio_adapter.py +4 -4
  78. autogen/agentchat/realtime/experimental/clients/gemini/client.py +7 -7
  79. autogen/agentchat/realtime/experimental/clients/oai/base_client.py +8 -8
  80. autogen/agentchat/realtime/experimental/clients/oai/rtc_client.py +6 -6
  81. autogen/agentchat/realtime/experimental/clients/realtime_client.py +10 -9
  82. autogen/agentchat/realtime/experimental/realtime_agent.py +10 -9
  83. autogen/agentchat/realtime/experimental/realtime_observer.py +3 -3
  84. autogen/agentchat/realtime/experimental/realtime_swarm.py +44 -44
  85. autogen/agentchat/user_proxy_agent.py +10 -9
  86. autogen/agentchat/utils.py +3 -3
  87. autogen/agents/contrib/time/time_reply_agent.py +6 -5
  88. autogen/agents/contrib/time/time_tool_agent.py +2 -1
  89. autogen/agents/experimental/deep_research/deep_research.py +3 -3
  90. autogen/agents/experimental/discord/discord.py +2 -2
  91. autogen/agents/experimental/document_agent/chroma_query_engine.py +29 -44
  92. autogen/agents/experimental/document_agent/docling_doc_ingest_agent.py +9 -14
  93. autogen/agents/experimental/document_agent/document_agent.py +15 -16
  94. autogen/agents/experimental/document_agent/document_conditions.py +3 -3
  95. autogen/agents/experimental/document_agent/document_utils.py +5 -9
  96. autogen/agents/experimental/document_agent/inmemory_query_engine.py +14 -20
  97. autogen/agents/experimental/document_agent/parser_utils.py +4 -4
  98. autogen/agents/experimental/document_agent/url_utils.py +14 -23
  99. autogen/agents/experimental/reasoning/reasoning_agent.py +33 -33
  100. autogen/agents/experimental/slack/slack.py +2 -2
  101. autogen/agents/experimental/telegram/telegram.py +2 -3
  102. autogen/agents/experimental/websurfer/websurfer.py +4 -4
  103. autogen/agents/experimental/wikipedia/wikipedia.py +5 -7
  104. autogen/browser_utils.py +8 -8
  105. autogen/cache/abstract_cache_base.py +5 -5
  106. autogen/cache/cache.py +12 -12
  107. autogen/cache/cache_factory.py +4 -4
  108. autogen/cache/cosmos_db_cache.py +9 -9
  109. autogen/cache/disk_cache.py +6 -6
  110. autogen/cache/in_memory_cache.py +4 -4
  111. autogen/cache/redis_cache.py +4 -4
  112. autogen/code_utils.py +18 -18
  113. autogen/coding/base.py +6 -6
  114. autogen/coding/docker_commandline_code_executor.py +9 -9
  115. autogen/coding/func_with_reqs.py +7 -6
  116. autogen/coding/jupyter/base.py +3 -3
  117. autogen/coding/jupyter/docker_jupyter_server.py +3 -4
  118. autogen/coding/jupyter/import_utils.py +3 -3
  119. autogen/coding/jupyter/jupyter_client.py +5 -5
  120. autogen/coding/jupyter/jupyter_code_executor.py +3 -4
  121. autogen/coding/jupyter/local_jupyter_server.py +2 -6
  122. autogen/coding/local_commandline_code_executor.py +8 -7
  123. autogen/coding/markdown_code_extractor.py +1 -2
  124. autogen/coding/utils.py +1 -2
  125. autogen/doc_utils.py +3 -2
  126. autogen/environments/docker_python_environment.py +19 -29
  127. autogen/environments/python_environment.py +8 -17
  128. autogen/environments/system_python_environment.py +3 -4
  129. autogen/environments/venv_python_environment.py +8 -12
  130. autogen/environments/working_directory.py +1 -2
  131. autogen/events/agent_events.py +106 -109
  132. autogen/events/base_event.py +6 -5
  133. autogen/events/client_events.py +15 -14
  134. autogen/events/helpers.py +1 -1
  135. autogen/events/print_event.py +4 -5
  136. autogen/fast_depends/_compat.py +10 -15
  137. autogen/fast_depends/core/build.py +17 -36
  138. autogen/fast_depends/core/model.py +64 -113
  139. autogen/fast_depends/dependencies/model.py +2 -1
  140. autogen/fast_depends/dependencies/provider.py +3 -2
  141. autogen/fast_depends/library/model.py +4 -4
  142. autogen/fast_depends/schema.py +7 -7
  143. autogen/fast_depends/use.py +17 -25
  144. autogen/fast_depends/utils.py +10 -30
  145. autogen/formatting_utils.py +6 -6
  146. autogen/graph_utils.py +1 -4
  147. autogen/import_utils.py +38 -27
  148. autogen/interop/crewai/crewai.py +2 -2
  149. autogen/interop/interoperable.py +2 -2
  150. autogen/interop/langchain/langchain_chat_model_factory.py +3 -2
  151. autogen/interop/langchain/langchain_tool.py +2 -6
  152. autogen/interop/litellm/litellm_config_factory.py +6 -7
  153. autogen/interop/pydantic_ai/pydantic_ai.py +4 -7
  154. autogen/interop/registry.py +2 -1
  155. autogen/io/base.py +5 -5
  156. autogen/io/run_response.py +33 -32
  157. autogen/io/websockets.py +6 -5
  158. autogen/json_utils.py +1 -2
  159. autogen/llm_config/__init__.py +11 -0
  160. autogen/llm_config/client.py +58 -0
  161. autogen/llm_config/config.py +384 -0
  162. autogen/llm_config/entry.py +154 -0
  163. autogen/logger/base_logger.py +4 -3
  164. autogen/logger/file_logger.py +2 -1
  165. autogen/logger/logger_factory.py +2 -2
  166. autogen/logger/logger_utils.py +2 -2
  167. autogen/logger/sqlite_logger.py +2 -1
  168. autogen/math_utils.py +4 -5
  169. autogen/mcp/__main__.py +6 -6
  170. autogen/mcp/helpers.py +4 -4
  171. autogen/mcp/mcp_client.py +170 -29
  172. autogen/mcp/mcp_proxy/fastapi_code_generator_helpers.py +3 -4
  173. autogen/mcp/mcp_proxy/mcp_proxy.py +23 -26
  174. autogen/mcp/mcp_proxy/operation_grouping.py +4 -5
  175. autogen/mcp/mcp_proxy/operation_renaming.py +6 -10
  176. autogen/mcp/mcp_proxy/security.py +2 -3
  177. autogen/messages/agent_messages.py +96 -98
  178. autogen/messages/base_message.py +6 -5
  179. autogen/messages/client_messages.py +15 -14
  180. autogen/messages/print_message.py +4 -5
  181. autogen/oai/__init__.py +1 -2
  182. autogen/oai/anthropic.py +42 -41
  183. autogen/oai/bedrock.py +68 -57
  184. autogen/oai/cerebras.py +26 -25
  185. autogen/oai/client.py +113 -139
  186. autogen/oai/client_utils.py +3 -3
  187. autogen/oai/cohere.py +34 -11
  188. autogen/oai/gemini.py +39 -17
  189. autogen/oai/gemini_types.py +11 -12
  190. autogen/oai/groq.py +22 -10
  191. autogen/oai/mistral.py +17 -11
  192. autogen/oai/oai_models/__init__.py +14 -2
  193. autogen/oai/oai_models/_models.py +2 -2
  194. autogen/oai/oai_models/chat_completion.py +13 -14
  195. autogen/oai/oai_models/chat_completion_message.py +11 -9
  196. autogen/oai/oai_models/chat_completion_message_tool_call.py +26 -3
  197. autogen/oai/oai_models/chat_completion_token_logprob.py +3 -4
  198. autogen/oai/oai_models/completion_usage.py +8 -9
  199. autogen/oai/ollama.py +19 -9
  200. autogen/oai/openai_responses.py +40 -17
  201. autogen/oai/openai_utils.py +48 -38
  202. autogen/oai/together.py +29 -14
  203. autogen/retrieve_utils.py +6 -7
  204. autogen/runtime_logging.py +5 -4
  205. autogen/token_count_utils.py +7 -4
  206. autogen/tools/contrib/time/time.py +0 -1
  207. autogen/tools/dependency_injection.py +5 -6
  208. autogen/tools/experimental/browser_use/browser_use.py +10 -10
  209. autogen/tools/experimental/code_execution/python_code_execution.py +5 -7
  210. autogen/tools/experimental/crawl4ai/crawl4ai.py +12 -15
  211. autogen/tools/experimental/deep_research/deep_research.py +9 -8
  212. autogen/tools/experimental/duckduckgo/duckduckgo_search.py +5 -11
  213. autogen/tools/experimental/firecrawl/firecrawl_tool.py +98 -115
  214. autogen/tools/experimental/google/authentication/credentials_local_provider.py +1 -1
  215. autogen/tools/experimental/google/drive/drive_functions.py +4 -4
  216. autogen/tools/experimental/google/drive/toolkit.py +5 -5
  217. autogen/tools/experimental/google_search/google_search.py +5 -5
  218. autogen/tools/experimental/google_search/youtube_search.py +5 -5
  219. autogen/tools/experimental/messageplatform/discord/discord.py +8 -12
  220. autogen/tools/experimental/messageplatform/slack/slack.py +14 -20
  221. autogen/tools/experimental/messageplatform/telegram/telegram.py +8 -12
  222. autogen/tools/experimental/perplexity/perplexity_search.py +18 -29
  223. autogen/tools/experimental/reliable/reliable.py +68 -74
  224. autogen/tools/experimental/searxng/searxng_search.py +20 -19
  225. autogen/tools/experimental/tavily/tavily_search.py +12 -19
  226. autogen/tools/experimental/web_search_preview/web_search_preview.py +13 -7
  227. autogen/tools/experimental/wikipedia/wikipedia.py +7 -10
  228. autogen/tools/function_utils.py +7 -7
  229. autogen/tools/tool.py +8 -6
  230. autogen/types.py +2 -2
  231. autogen/version.py +1 -1
  232. ag2-0.9.7.dist-info/RECORD +0 -421
  233. autogen/llm_config.py +0 -385
  234. {ag2-0.9.7.dist-info → ag2-0.9.9.dist-info}/WHEEL +0 -0
  235. {ag2-0.9.7.dist-info → ag2-0.9.9.dist-info}/licenses/LICENSE +0 -0
  236. {ag2-0.9.7.dist-info → ag2-0.9.9.dist-info}/licenses/NOTICE.md +0 -0
@@ -2,7 +2,8 @@
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
 
5
- from typing import TYPE_CHECKING, Any, Callable, Optional, Tuple, Union
5
+ from collections.abc import Callable
6
+ from typing import TYPE_CHECKING, Any, Optional
6
7
 
7
8
  from ..context_variables import ContextVariables
8
9
  from ..targets.group_manager_target import GroupManagerSelectionMessage, GroupManagerTarget
@@ -28,11 +29,11 @@ class AutoPattern(Pattern):
28
29
  initial_agent: "ConversableAgent",
29
30
  agents: list["ConversableAgent"],
30
31
  user_agent: Optional["ConversableAgent"] = None,
31
- group_manager_args: Optional[dict[str, Any]] = None,
32
- context_variables: Optional[ContextVariables] = None,
33
- selection_message: Optional[GroupManagerSelectionMessage] = None,
32
+ group_manager_args: dict[str, Any] | None = None,
33
+ context_variables: ContextVariables | None = None,
34
+ selection_message: GroupManagerSelectionMessage | None = None,
34
35
  exclude_transit_message: bool = True,
35
- summary_method: Optional[Union[str, Callable[..., Any]]] = "last_msg",
36
+ summary_method: str | Callable[..., Any] | None = "last_msg",
36
37
  ):
37
38
  """Initialize the AutoPattern.
38
39
 
@@ -70,8 +71,8 @@ class AutoPattern(Pattern):
70
71
  def prepare_group_chat(
71
72
  self,
72
73
  max_rounds: int,
73
- messages: Union[list[dict[str, Any]], str],
74
- ) -> Tuple[
74
+ messages: list[dict[str, Any]] | str,
75
+ ) -> tuple[
75
76
  list["ConversableAgent"],
76
77
  list["ConversableAgent"],
77
78
  Optional["ConversableAgent"],
@@ -2,7 +2,8 @@
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
 
5
- from typing import TYPE_CHECKING, Any, Callable, Optional, Tuple, Union
5
+ from collections.abc import Callable
6
+ from typing import TYPE_CHECKING, Any, Optional
6
7
 
7
8
  from ..context_variables import ContextVariables
8
9
  from ..group_tool_executor import GroupToolExecutor
@@ -22,10 +23,10 @@ class ManualPattern(Pattern):
22
23
  initial_agent: "ConversableAgent",
23
24
  agents: list["ConversableAgent"],
24
25
  user_agent: Optional["ConversableAgent"] = None,
25
- group_manager_args: Optional[dict[str, Any]] = None,
26
- context_variables: Optional[ContextVariables] = None,
26
+ group_manager_args: dict[str, Any] | None = None,
27
+ context_variables: ContextVariables | None = None,
27
28
  exclude_transit_message: bool = True,
28
- summary_method: Optional[Union[str, Callable[..., Any]]] = "last_msg",
29
+ summary_method: str | Callable[..., Any] | None = "last_msg",
29
30
  ):
30
31
  """Initialize the ManualPattern.
31
32
 
@@ -57,8 +58,8 @@ class ManualPattern(Pattern):
57
58
  def prepare_group_chat(
58
59
  self,
59
60
  max_rounds: int,
60
- messages: Union[list[dict[str, Any]], str],
61
- ) -> Tuple[
61
+ messages: list[dict[str, Any]] | str,
62
+ ) -> tuple[
62
63
  list["ConversableAgent"],
63
64
  list["ConversableAgent"],
64
65
  Optional["ConversableAgent"],
@@ -6,7 +6,8 @@
6
6
  # Uses the group chat or the agents' handoffs to create a pattern
7
7
 
8
8
  from abc import ABC, abstractmethod
9
- from typing import TYPE_CHECKING, Any, Callable, Optional, Tuple, Union
9
+ from collections.abc import Callable
10
+ from typing import TYPE_CHECKING, Any, Optional
10
11
 
11
12
  from ..context_variables import ContextVariables
12
13
  from ..group_utils import (
@@ -43,11 +44,11 @@ class Pattern(ABC):
43
44
  initial_agent: "ConversableAgent",
44
45
  agents: list["ConversableAgent"],
45
46
  user_agent: Optional["ConversableAgent"] = None,
46
- group_manager_args: Optional[dict[str, Any]] = None,
47
- context_variables: Optional[ContextVariables] = None,
48
- group_after_work: Optional[TransitionTarget] = None,
47
+ group_manager_args: dict[str, Any] | None = None,
48
+ context_variables: ContextVariables | None = None,
49
+ group_after_work: TransitionTarget | None = None,
49
50
  exclude_transit_message: bool = True,
50
- summary_method: Optional[Union[str, Callable[..., Any]]] = "last_msg",
51
+ summary_method: str | Callable[..., Any] | None = "last_msg",
51
52
  ):
52
53
  """Initialize the pattern with the required components.
53
54
 
@@ -74,8 +75,8 @@ class Pattern(ABC):
74
75
  def prepare_group_chat(
75
76
  self,
76
77
  max_rounds: int,
77
- messages: Union[list[dict[str, Any]], str],
78
- ) -> Tuple[
78
+ messages: list[dict[str, Any]] | str,
79
+ ) -> tuple[
79
80
  list["ConversableAgent"],
80
81
  list["ConversableAgent"],
81
82
  Optional["ConversableAgent"],
@@ -185,10 +186,10 @@ class Pattern(ABC):
185
186
  initial_agent: "ConversableAgent",
186
187
  agents: list["ConversableAgent"],
187
188
  user_agent: Optional["ConversableAgent"] = None,
188
- group_manager_args: Optional[dict[str, Any]] = None,
189
- context_variables: Optional[ContextVariables] = None,
189
+ group_manager_args: dict[str, Any] | None = None,
190
+ context_variables: ContextVariables | None = None,
190
191
  exclude_transit_message: bool = True,
191
- summary_method: Optional[Union[str, Callable[..., Any]]] = "last_msg",
192
+ summary_method: str | Callable[..., Any] | None = "last_msg",
192
193
  ) -> "DefaultPattern":
193
194
  """Create a default pattern with minimal configuration.
194
195
 
@@ -228,8 +229,8 @@ class DefaultPattern(Pattern):
228
229
  def prepare_group_chat(
229
230
  self,
230
231
  max_rounds: int,
231
- messages: Union[list[dict[str, Any]], str],
232
- ) -> Tuple[
232
+ messages: list[dict[str, Any]] | str,
233
+ ) -> tuple[
233
234
  list["ConversableAgent"],
234
235
  list["ConversableAgent"],
235
236
  Optional["ConversableAgent"],
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
 
5
- from typing import TYPE_CHECKING, Any, Optional, Tuple, Union
5
+ from typing import TYPE_CHECKING, Any, Optional
6
6
 
7
7
  from ..context_variables import ContextVariables
8
8
  from ..targets.transition_target import RandomAgentTarget, TransitionTarget
@@ -36,8 +36,8 @@ class RandomPattern(Pattern):
36
36
  def prepare_group_chat(
37
37
  self,
38
38
  max_rounds: int,
39
- messages: Union[list[dict[str, Any]], str],
40
- ) -> Tuple[
39
+ messages: list[dict[str, Any]] | str,
40
+ ) -> tuple[
41
41
  list["ConversableAgent"],
42
42
  list["ConversableAgent"],
43
43
  Optional["ConversableAgent"],
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
 
5
- from typing import TYPE_CHECKING, Any, Optional, Tuple, Union
5
+ from typing import TYPE_CHECKING, Any, Optional
6
6
 
7
7
  from ..context_variables import ContextVariables
8
8
  from ..targets.transition_target import AgentTarget, TransitionTarget
@@ -47,8 +47,8 @@ class RoundRobinPattern(Pattern):
47
47
  def prepare_group_chat(
48
48
  self,
49
49
  max_rounds: int,
50
- messages: Union[list[dict[str, Any]], str],
51
- ) -> Tuple[
50
+ messages: list[dict[str, Any]] | str,
51
+ ) -> tuple[
52
52
  list["ConversableAgent"],
53
53
  list["ConversableAgent"],
54
54
  Optional["ConversableAgent"],
@@ -6,8 +6,6 @@
6
6
  __all__ = ["ReplyResult"]
7
7
 
8
8
 
9
- from typing import Optional
10
-
11
9
  from pydantic import BaseModel
12
10
 
13
11
  from .context_variables import ContextVariables
@@ -18,8 +16,8 @@ class ReplyResult(BaseModel):
18
16
  """Result of a tool call that is used to provide the return message and the target to transition to."""
19
17
 
20
18
  message: str
21
- target: Optional[TransitionTarget] = None
22
- context_variables: Optional[ContextVariables] = None
19
+ target: TransitionTarget | None = None
20
+ context_variables: ContextVariables | None = None
23
21
 
24
22
  def __str__(self) -> str:
25
23
  """The string representation for ReplyResult will be just the message."""
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
 
5
- from typing import TYPE_CHECKING, Optional, Union
5
+ from typing import TYPE_CHECKING
6
6
 
7
7
  from pydantic import BaseModel
8
8
 
@@ -19,11 +19,11 @@ class SpeakerSelectionResult(BaseModel):
19
19
  This class can return an Agent, a None to end the conversation, or a string for a speaker selection method.
20
20
  """
21
21
 
22
- terminate: Optional[bool] = None
23
- agent_name: Optional[str] = None
24
- speaker_selection_method: Optional[str] = None
22
+ terminate: bool | None = None
23
+ agent_name: str | None = None
24
+ speaker_selection_method: str | None = None
25
25
 
26
- def get_speaker_selection_result(self, groupchat: "GroupChat") -> Optional[Union[Agent, str]]:
26
+ def get_speaker_selection_result(self, groupchat: "GroupChat") -> Agent | str | None:
27
27
  """Get the speaker selection result. If None, the conversation will end."""
28
28
  if self.agent_name is not None:
29
29
  # Find the agent by name in the groupchat
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
 
5
- from typing import TYPE_CHECKING, Any, Optional, Union
5
+ from typing import TYPE_CHECKING, Any, Optional
6
6
 
7
7
  from pydantic import BaseModel
8
8
 
@@ -25,10 +25,11 @@ __all__ = ["GroupChatConfig", "GroupChatTarget"]
25
25
  class GroupChatConfig(BaseModel):
26
26
  """Configuration for a group chat transition target.
27
27
 
28
- Note: If context_variables are not passed in, the outer context variables will be passed in"""
28
+ Note: If context_variables are not passed in, the outer context variables will be passed in
29
+ """
29
30
 
30
31
  pattern: "Pattern"
31
- messages: Union[list[dict[str, Any]], str]
32
+ messages: list[dict[str, Any]] | str
32
33
  max_rounds: int = 20
33
34
 
34
35
 
@@ -88,10 +89,10 @@ class GroupChatTarget(TransitionTarget):
88
89
  # Define the reply function that will run the group chat
89
90
  def group_chat_reply(
90
91
  agent: "ConversableAgent",
91
- messages: Optional[list[dict[str, Any]]] = None,
92
+ messages: list[dict[str, Any]] | None = None,
92
93
  sender: Optional["Agent"] = None,
93
- config: Optional[Any] = None,
94
- ) -> tuple[bool, Optional[dict[str, Any]]]:
94
+ config: Any | None = None,
95
+ ) -> tuple[bool, dict[str, Any] | None]:
95
96
  """Run the inner group chat and return its results as a reply."""
96
97
  # Get the configuration stored directly on the agent
97
98
  group_config = agent._group_chat_config # type: ignore[attr-defined]
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
 
5
- from typing import TYPE_CHECKING, Any, Optional, Type, Union
5
+ from typing import TYPE_CHECKING, Any, Optional
6
6
 
7
7
  from pydantic import BaseModel, field_validator
8
8
 
@@ -24,7 +24,7 @@ __all__ = ["GroupManagerTarget"]
24
24
  def prepare_groupchat_auto_speaker(
25
25
  groupchat: "GroupChat",
26
26
  last_group_agent: "ConversableAgent",
27
- group_chat_manager_selection_msg: Optional[Any],
27
+ group_chat_manager_selection_msg: Any | None,
28
28
  ) -> None:
29
29
  """Prepare the group chat for auto speaker selection, includes updating or restore the groupchat speaker selection message.
30
30
 
@@ -88,7 +88,7 @@ class GroupManagerSelectionMessageContextStr(GroupManagerSelectionMessage):
88
88
  # We will replace {agentlist} with another term and return it later for use with the internal group chat auto speaker selection
89
89
  # Otherwise our format will fail
90
90
  @field_validator("context_str_template", mode="before")
91
- def _replace_agentlist_placeholder(cls: Type["GroupManagerSelectionMessageContextStr"], v: Any) -> Union[str, Any]: # noqa: N805
91
+ def _replace_agentlist_placeholder(cls: type["GroupManagerSelectionMessageContextStr"], v: Any) -> str | Any: # noqa: N805
92
92
  """Replace {agentlist} placeholder before validation/assignment."""
93
93
  if isinstance(v, str):
94
94
  if "{agentlist}" in v:
@@ -112,7 +112,7 @@ class GroupManagerSelectionMessageContextStr(GroupManagerSelectionMessage):
112
112
  class GroupManagerTarget(TransitionTarget):
113
113
  """Target that represents an agent by name."""
114
114
 
115
- selection_message: Optional[GroupManagerSelectionMessage] = None
115
+ selection_message: GroupManagerSelectionMessage | None = None
116
116
 
117
117
  def can_resolve_for_speaker_selection(self) -> bool:
118
118
  """Check if the target can resolve for speaker selection."""
@@ -71,7 +71,8 @@ class TransitionTarget(BaseModel):
71
71
  def activate_target(self, groupchat: "GroupChat") -> None:
72
72
  """Activate the target in the groupchat, setting the next target for GroupToolExecutor.
73
73
 
74
- The Tool Executor's next target attribute will be picked up on the next iteration when _determine_next_agent is called"""
74
+ The Tool Executor's next target attribute will be picked up on the next iteration when _determine_next_agent is called
75
+ """
75
76
  for agent in groupchat.agents: # type: ignore[attr-defined]
76
77
  # get the GroupToolExecutor agent
77
78
  if type(agent).__name__ == "GroupToolExecutor":
@@ -10,8 +10,9 @@ import logging
10
10
  import random
11
11
  import re
12
12
  import sys
13
+ from collections.abc import Callable
13
14
  from dataclasses import dataclass, field
14
- from typing import Any, Callable, Literal, Optional, Union
15
+ from typing import Any, Literal
15
16
 
16
17
  from ..code_utils import content_str
17
18
  from ..doc_utils import export_module
@@ -30,8 +31,7 @@ from ..events.agent_events import (
30
31
  from ..exception_utils import AgentNameConflictError, NoEligibleSpeakerError, UndefinedNextAgentError
31
32
  from ..graph_utils import check_graph_validity, invert_disallowed_to_allowed
32
33
  from ..io.base import IOStream
33
- from ..llm_config import LLMConfig
34
- from ..oai.client import ModelClient
34
+ from ..llm_config import LLMConfig, ModelClient
35
35
  from ..runtime_logging import log_new_agent, logging_enabled
36
36
  from .agent import Agent
37
37
  from .contrib.capabilities import transform_messages
@@ -134,10 +134,10 @@ class GroupChat:
134
134
  max_round: int = 10
135
135
  admin_name: str = "Admin"
136
136
  func_call_filter: bool = True
137
- speaker_selection_method: Union[Literal["auto", "manual", "random", "round_robin"], Callable[..., Any]] = "auto"
137
+ speaker_selection_method: Literal["auto", "manual", "random", "round_robin"] | Callable[..., Any] = "auto"
138
138
  max_retries_for_selecting_speaker: int = 2
139
- allow_repeat_speaker: Optional[Union[bool, list[Agent]]] = None
140
- allowed_or_disallowed_speaker_transitions: Optional[dict[str, Any]] = None
139
+ allow_repeat_speaker: bool | list[Agent] | None = None
140
+ allowed_or_disallowed_speaker_transitions: dict[str, Any] | None = None
141
141
  speaker_transitions_type: Literal["allowed", "disallowed", None] = None
142
142
  enable_clear_history: bool = False
143
143
  send_introductions: bool = False
@@ -159,11 +159,11 @@ class GroupChat:
159
159
  The names are case-sensitive and should not be abbreviated or changed.
160
160
  The only names that are accepted are {agentlist}.
161
161
  Respond with ONLY the name of the speaker and DO NOT provide a reason."""
162
- select_speaker_transform_messages: Optional[transform_messages.TransformMessages] = None
163
- select_speaker_auto_verbose: Optional[bool] = False
164
- select_speaker_auto_model_client_cls: Optional[Union[ModelClient, list[ModelClient]]] = None
165
- select_speaker_auto_llm_config: Optional[Union[LLMConfig, dict[str, Any], Literal[False]]] = None
166
- role_for_select_speaker_messages: Optional[str] = "system"
162
+ select_speaker_transform_messages: transform_messages.TransformMessages | None = None
163
+ select_speaker_auto_verbose: bool | None = False
164
+ select_speaker_auto_model_client_cls: ModelClient | list[ModelClient] | None = None
165
+ select_speaker_auto_llm_config: LLMConfig | dict[str, Any] | Literal[False] | None = None
166
+ role_for_select_speaker_messages: str | None = "system"
167
167
 
168
168
  _VALID_SPEAKER_SELECTION_METHODS = ["auto", "manual", "random", "round_robin"]
169
169
  _VALID_SPEAKER_TRANSITIONS_TYPE = ["allowed", "disallowed", None]
@@ -315,9 +315,7 @@ class GroupChat:
315
315
  message["content"] = content_str(message["content"])
316
316
  self.messages.append(message)
317
317
 
318
- def agent_by_name(
319
- self, name: str, recursive: bool = False, raise_on_name_conflict: bool = False
320
- ) -> Optional[Agent]:
318
+ def agent_by_name(self, name: str, recursive: bool = False, raise_on_name_conflict: bool = False) -> Agent | None:
321
319
  """Returns the agent with a given name. If recursive is True, it will search in nested teams."""
322
320
  agents = self.nested_agents() if recursive else self.agents
323
321
  filtered_agents = [agent for agent in agents if agent.name == name]
@@ -336,7 +334,7 @@ class GroupChat:
336
334
  agents.extend(agent.groupchat.nested_agents())
337
335
  return agents
338
336
 
339
- def next_agent(self, agent: Agent, agents: Optional[list[Agent]] = None) -> Agent:
337
+ def next_agent(self, agent: Agent, agents: list[Agent] | None = None) -> Agent:
340
338
  """Return the next agent in the list."""
341
339
  if agents is None:
342
340
  agents = self.agents
@@ -360,7 +358,7 @@ class GroupChat:
360
358
  # Explicitly handle cases where no valid next agent exists in the provided subset.
361
359
  raise UndefinedNextAgentError()
362
360
 
363
- def select_speaker_msg(self, agents: Optional[list[Agent]] = None) -> str:
361
+ def select_speaker_msg(self, agents: list[Agent] | None = None) -> str:
364
362
  """Return the system message for selecting the next speaker. This is always the *first* message in the context."""
365
363
  if agents is None:
366
364
  agents = self.agents
@@ -371,7 +369,7 @@ class GroupChat:
371
369
  return_msg = self.select_speaker_message_template.format(roles=roles, agentlist=agentlist)
372
370
  return return_msg
373
371
 
374
- def select_speaker_prompt(self, agents: Optional[list[Agent]] = None) -> str:
372
+ def select_speaker_prompt(self, agents: list[Agent] | None = None) -> str:
375
373
  """Return the floating system prompt selecting the next speaker.
376
374
  This is always the *last* message in the context.
377
375
  Will return None if the select_speaker_prompt_template is None.
@@ -387,7 +385,7 @@ class GroupChat:
387
385
  return_prompt = f"{self.select_speaker_prompt_template}".replace("{agentlist}", agentlist)
388
386
  return return_prompt
389
387
 
390
- def introductions_msg(self, agents: Optional[list[Agent]] = None) -> str:
388
+ def introductions_msg(self, agents: list[Agent] | None = None) -> str:
391
389
  """Return the system message for selecting the next speaker. This is always the *first* message in the context."""
392
390
  if agents is None:
393
391
  agents = self.agents
@@ -398,7 +396,7 @@ class GroupChat:
398
396
 
399
397
  return f"{intro_msg}\n\n{participant_roles}"
400
398
 
401
- def manual_select_speaker(self, agents: Optional[list[Agent]] = None) -> Union[Agent, None]:
399
+ def manual_select_speaker(self, agents: list[Agent] | None = None) -> Agent | None:
402
400
  """Manually select the next speaker."""
403
401
  iostream = IOStream.get_default()
404
402
 
@@ -429,7 +427,7 @@ class GroupChat:
429
427
  iostream.send(SelectSpeakerInvalidInputEvent(agents=agents))
430
428
  return None
431
429
 
432
- def random_select_speaker(self, agents: Optional[list[Agent]] = None) -> Union[Agent, None]:
430
+ def random_select_speaker(self, agents: list[Agent] | None = None) -> Agent | None:
433
431
  """Randomly select the next speaker."""
434
432
  if agents is None:
435
433
  agents = self.agents
@@ -438,7 +436,7 @@ class GroupChat:
438
436
  def _prepare_and_select_agents(
439
437
  self,
440
438
  last_speaker: Agent,
441
- ) -> tuple[Optional[Agent], list[Agent], Optional[list[dict[str, Any]]]]:
439
+ ) -> tuple[Agent | None, list[Agent], list[dict[str, Any]] | None]:
442
440
  # If self.speaker_selection_method is a callable, call it to get the next speaker.
443
441
  # If self.speaker_selection_method is a string, return it.
444
442
  speaker_selection_method = self.speaker_selection_method
@@ -577,7 +575,7 @@ class GroupChat:
577
575
  return self.next_agent(last_speaker)
578
576
 
579
577
  # auto speaker selection with 2-agent chat
580
- return self._auto_select_speaker(last_speaker, selector, messages, agents)
578
+ return self._auto_select_speaker(last_speaker, selector, messages if messages else self.messages, agents)
581
579
 
582
580
  async def a_select_speaker(self, last_speaker: Agent, selector: ConversableAgent) -> Agent:
583
581
  """Select the next speaker (with requery), asynchronously."""
@@ -589,9 +587,9 @@ class GroupChat:
589
587
  return self.next_agent(last_speaker)
590
588
 
591
589
  # auto speaker selection with 2-agent chat
592
- return await self.a_auto_select_speaker(last_speaker, selector, messages, agents)
590
+ return await self.a_auto_select_speaker(last_speaker, selector, messages if messages else self.messages, agents)
593
591
 
594
- def _finalize_speaker(self, last_speaker: Agent, final: bool, name: str, agents: Optional[list[Agent]]) -> Agent:
592
+ def _finalize_speaker(self, last_speaker: Agent, final: bool, name: str, agents: list[Agent] | None) -> Agent:
595
593
  if not final:
596
594
  # the LLM client is None, thus no reply is generated. Use round robin instead.
597
595
  return self.next_agent(last_speaker, agents)
@@ -653,7 +651,7 @@ class GroupChat:
653
651
  self._register_client_from_config(agent, self.select_speaker_auto_llm_config)
654
652
 
655
653
  def _create_internal_agents(
656
- self, agents, max_attempts, messages, validate_speaker_name, selector: Optional[ConversableAgent] = None
654
+ self, agents, max_attempts, messages, validate_speaker_name, selector: ConversableAgent | None = None
657
655
  ):
658
656
  checking_agent = ConversableAgent("checking_agent", default_auto_reply=max_attempts)
659
657
 
@@ -691,8 +689,8 @@ class GroupChat:
691
689
  self,
692
690
  last_speaker: Agent,
693
691
  selector: ConversableAgent,
694
- messages: Optional[list[dict[str, Any]]],
695
- agents: Optional[list[Agent]],
692
+ messages: list[dict[str, Any]] | None,
693
+ agents: list[Agent] | None,
696
694
  ) -> Agent:
697
695
  """Selects next speaker for the "auto" speaker selection method. Utilises its own two-agent chat to determine the next speaker and supports requerying.
698
696
 
@@ -726,9 +724,7 @@ class GroupChat:
726
724
  attempt = 0
727
725
 
728
726
  # Registered reply function for checking_agent, checks the result of the response for agent names
729
- def validate_speaker_name(
730
- recipient, messages, sender, config
731
- ) -> tuple[bool, Optional[Union[str, dict[str, Any]]]]:
727
+ def validate_speaker_name(recipient, messages, sender, config) -> tuple[bool, str | dict[str, Any] | None]:
732
728
  # The number of retries left, starting at max_retries_for_selecting_speaker
733
729
  nonlocal attempts_left
734
730
  nonlocal attempt
@@ -776,8 +772,8 @@ class GroupChat:
776
772
  self,
777
773
  last_speaker: Agent,
778
774
  selector: ConversableAgent,
779
- messages: Optional[list[dict[str, Any]]],
780
- agents: Optional[list[Agent]],
775
+ messages: list[dict[str, Any]] | None,
776
+ agents: list[Agent] | None,
781
777
  ) -> Agent:
782
778
  """(Asynchronous) Selects next speaker for the "auto" speaker selection method. Utilises its own two-agent chat to determine the next speaker and supports requerying.
783
779
 
@@ -810,9 +806,7 @@ class GroupChat:
810
806
  attempt = 0
811
807
 
812
808
  # Registered reply function for checking_agent, checks the result of the response for agent names
813
- def validate_speaker_name(
814
- recipient, messages, sender, config
815
- ) -> tuple[bool, Optional[Union[str, dict[str, Any]]]]:
809
+ def validate_speaker_name(recipient, messages, sender, config) -> tuple[bool, str | dict[str, Any] | None]:
816
810
  # The number of retries left, starting at max_retries_for_selecting_speaker
817
811
  nonlocal attempts_left
818
812
  nonlocal attempt
@@ -857,21 +851,22 @@ class GroupChat:
857
851
 
858
852
  def _validate_speaker_name(
859
853
  self, recipient, messages, sender, config, attempts_left, attempt, agents
860
- ) -> tuple[bool, Optional[Union[str, dict[str, Any]]]]:
854
+ ) -> tuple[bool, str | dict[str, Any] | None]:
861
855
  """Validates the speaker response for each round in the internal 2-agent
862
856
  chat within the auto select speaker method.
863
857
 
864
858
  Used by auto_select_speaker and a_auto_select_speaker.
865
859
  """
866
860
  # Validate the speaker name selected
867
- select_name = messages[-1]["content"].strip()
868
-
869
- mentions = self._mentioned_agents(select_name, agents)
861
+ if messages and (name := messages[-1].get("content")):
862
+ mentions = self._mentioned_agents(name.strip(), agents)
863
+ else:
864
+ mentions = []
865
+ no_of_mentions = len(mentions)
870
866
 
871
867
  # Output the query and requery results
872
868
  if self.select_speaker_auto_verbose:
873
869
  iostream = IOStream.get_default()
874
- no_of_mentions = len(mentions)
875
870
  if no_of_mentions == 1:
876
871
  # Success on retry, we have just one name mentioned
877
872
  iostream.send(
@@ -901,14 +896,14 @@ class GroupChat:
901
896
  )
902
897
  )
903
898
 
904
- if len(mentions) == 1:
899
+ if no_of_mentions == 1:
905
900
  # Success on retry, we have just one name mentioned
906
901
  selected_agent_name = next(iter(mentions))
907
902
 
908
903
  # Add the selected agent to the response so we can return it
909
904
  messages.append({"role": "user", "content": f"[AGENT SELECTED]{selected_agent_name}"})
910
905
 
911
- elif len(mentions) > 1:
906
+ elif no_of_mentions > 1:
912
907
  # More than one name on requery so add additional reminder prompt for next retry
913
908
 
914
909
  if attempts_left:
@@ -948,7 +943,7 @@ class GroupChat:
948
943
 
949
944
  return True, None
950
945
 
951
- def _process_speaker_selection_result(self, result, last_speaker: ConversableAgent, agents: Optional[list[Agent]]):
946
+ def _process_speaker_selection_result(self, result, last_speaker: ConversableAgent, agents: list[Agent] | None):
952
947
  """Checks the result of the auto_select_speaker function, returning the
953
948
  agent to speak.
954
949
 
@@ -983,7 +978,7 @@ class GroupChat:
983
978
  roles.append(f"{agent.name}: {agent.description}".strip())
984
979
  return "\n".join(roles)
985
980
 
986
- def _mentioned_agents(self, message_content: Union[str, list], agents: Optional[list[Agent]]) -> dict:
981
+ def _mentioned_agents(self, message_content: str | list, agents: list[Agent] | None) -> dict:
987
982
  """Counts the number of times each agent is mentioned in the provided message content.
988
983
  Agent names will match under any of the following conditions (all case-sensitive):
989
984
  - Exact name match
@@ -1026,9 +1021,10 @@ class GroupChat:
1026
1021
  def _run_input_guardrails(
1027
1022
  self,
1028
1023
  agent: "ConversableAgent",
1029
- messages: Optional[list[dict[str, Any]]] = None,
1030
- ) -> Optional[str]:
1024
+ messages: list[dict[str, Any]] | None = None,
1025
+ ) -> str | None:
1031
1026
  """Run input guardrails for an agent before the reply is generated.
1027
+
1032
1028
  Args:
1033
1029
  agent (ConversableAgent): The agent whose input guardrails to run.
1034
1030
  messages (Optional[list[dict[str, Any]]]): The messages to check against the guardrails.
@@ -1043,6 +1039,7 @@ class GroupChat:
1043
1039
 
1044
1040
  def _run_output_guardrails(self, agent: "ConversableAgent", reply: str) -> None:
1045
1041
  """Run output guardrails for an agent after the reply is generated.
1042
+
1046
1043
  Args:
1047
1044
  agent (ConversableAgent): The agent whose output guardrails to run.
1048
1045
  reply (str): The reply generated by the agent.
@@ -1063,11 +1060,11 @@ class GroupChatManager(ConversableAgent):
1063
1060
  def __init__(
1064
1061
  self,
1065
1062
  groupchat: GroupChat,
1066
- name: Optional[str] = "chat_manager",
1063
+ name: str | None = "chat_manager",
1067
1064
  # unlimited consecutive auto reply by default
1068
- max_consecutive_auto_reply: Optional[int] = sys.maxsize,
1065
+ max_consecutive_auto_reply: int | None = sys.maxsize,
1069
1066
  human_input_mode: Literal["ALWAYS", "NEVER", "TERMINATE"] = "NEVER",
1070
- system_message: Optional[Union[str, list]] = "Group chat manager.",
1067
+ system_message: str | list | None = "Group chat manager.",
1071
1068
  silent: bool = False,
1072
1069
  **kwargs: Any,
1073
1070
  ):
@@ -1177,10 +1174,10 @@ class GroupChatManager(ConversableAgent):
1177
1174
 
1178
1175
  def run_chat(
1179
1176
  self,
1180
- messages: Optional[list[dict[str, Any]]] = None,
1181
- sender: Optional[Agent] = None,
1182
- config: Optional[GroupChat] = None,
1183
- ) -> tuple[bool, Optional[str]]:
1177
+ messages: list[dict[str, Any]] | None = None,
1178
+ sender: Agent | None = None,
1179
+ config: GroupChat | None = None,
1180
+ ) -> tuple[bool, str | None]:
1184
1181
  """Run a group chat."""
1185
1182
  iostream = IOStream.get_default()
1186
1183
 
@@ -1293,9 +1290,9 @@ class GroupChatManager(ConversableAgent):
1293
1290
 
1294
1291
  async def a_run_chat(
1295
1292
  self,
1296
- messages: Optional[list[dict[str, Any]]] = None,
1297
- sender: Optional[Agent] = None,
1298
- config: Optional[GroupChat] = None,
1293
+ messages: list[dict[str, Any]] | None = None,
1294
+ sender: Agent | None = None,
1295
+ config: GroupChat | None = None,
1299
1296
  ):
1300
1297
  """Run a group chat asynchronously."""
1301
1298
  iostream = IOStream.get_default()
@@ -1410,9 +1407,9 @@ class GroupChatManager(ConversableAgent):
1410
1407
 
1411
1408
  def resume(
1412
1409
  self,
1413
- messages: Union[list[dict[str, Any]], str],
1414
- remove_termination_string: Optional[Union[str, Callable[[str], str]]] = None,
1415
- silent: Optional[bool] = False,
1410
+ messages: list[dict[str, Any]] | str,
1411
+ remove_termination_string: str | Callable[[str], str] | None = None,
1412
+ silent: bool | None = False,
1416
1413
  ) -> tuple[ConversableAgent, dict[str, Any]]:
1417
1414
  """Resumes a group chat using the previous messages as a starting point. Requires the agents, group chat, and group chat manager to be established
1418
1415
  as per the original group chat.
@@ -1513,9 +1510,9 @@ class GroupChatManager(ConversableAgent):
1513
1510
 
1514
1511
  async def a_resume(
1515
1512
  self,
1516
- messages: Union[list[dict[str, Any]], str],
1517
- remove_termination_string: Optional[Union[str, Callable[[str], str]]] = None,
1518
- silent: Optional[bool] = False,
1513
+ messages: list[dict[str, Any]] | str,
1514
+ remove_termination_string: str | Callable[[str], str] | None = None,
1515
+ silent: bool | None = False,
1519
1516
  ) -> tuple[ConversableAgent, dict[str, Any]]:
1520
1517
  """Resumes a group chat using the previous messages as a starting point, asynchronously. Requires the agents, group chat, and group chat manager to be established
1521
1518
  as per the original group chat.
@@ -1639,7 +1636,7 @@ class GroupChatManager(ConversableAgent):
1639
1636
  raise Exception(f"Agent name in message doesn't exist as agent in group chat: {message['name']}")
1640
1637
 
1641
1638
  def _process_resume_termination(
1642
- self, remove_termination_string: Union[str, Callable[[str], str]], messages: list[dict[str, Any]]
1639
+ self, remove_termination_string: str | Callable[[str], str], messages: list[dict[str, Any]]
1643
1640
  ):
1644
1641
  """Removes termination string, if required, and checks if termination may occur.
1645
1642