waldiez 0.4.6__py3-none-any.whl → 0.4.8__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 waldiez might be problematic. Click here for more details.

Files changed (244) hide show
  1. waldiez/__init__.py +5 -5
  2. waldiez/_version.py +1 -1
  3. waldiez/cli.py +112 -73
  4. waldiez/exporter.py +61 -19
  5. waldiez/exporting/__init__.py +25 -6
  6. waldiez/exporting/agent/__init__.py +7 -3
  7. waldiez/exporting/agent/code_execution.py +114 -0
  8. waldiez/exporting/agent/exporter.py +354 -0
  9. waldiez/exporting/agent/extras/__init__.py +15 -0
  10. waldiez/exporting/agent/extras/captain_agent_extras.py +315 -0
  11. waldiez/exporting/agent/extras/group/target.py +178 -0
  12. waldiez/exporting/agent/extras/group_manager_agent_extas.py +500 -0
  13. waldiez/exporting/agent/extras/group_member_extras.py +181 -0
  14. waldiez/exporting/agent/extras/handoffs/__init__.py +19 -0
  15. waldiez/exporting/agent/extras/handoffs/after_work.py +78 -0
  16. waldiez/exporting/agent/extras/handoffs/available.py +74 -0
  17. waldiez/exporting/agent/extras/handoffs/condition.py +158 -0
  18. waldiez/exporting/agent/extras/handoffs/handoff.py +171 -0
  19. waldiez/exporting/agent/extras/handoffs/target.py +189 -0
  20. waldiez/exporting/agent/extras/rag/__init__.py +10 -0
  21. waldiez/exporting/agent/{utils/rag_user/chroma_utils.py → extras/rag/chroma_extras.py} +16 -15
  22. waldiez/exporting/agent/{utils/rag_user/mongo_utils.py → extras/rag/mongo_extras.py} +10 -10
  23. waldiez/exporting/agent/{utils/rag_user/pgvector_utils.py → extras/rag/pgvector_extras.py} +13 -13
  24. waldiez/exporting/agent/{utils/rag_user/qdrant_utils.py → extras/rag/qdrant_extras.py} +13 -13
  25. waldiez/exporting/agent/{utils/rag_user/vector_db.py → extras/rag/vector_db_extras.py} +59 -46
  26. waldiez/exporting/agent/extras/rag_user_proxy_agent_extras.py +245 -0
  27. waldiez/exporting/agent/extras/reasoning_agent_extras.py +88 -0
  28. waldiez/exporting/agent/factory.py +95 -0
  29. waldiez/exporting/agent/processor.py +150 -0
  30. waldiez/exporting/agent/system_message.py +36 -0
  31. waldiez/exporting/agent/termination.py +50 -0
  32. waldiez/exporting/chats/__init__.py +7 -3
  33. waldiez/exporting/chats/exporter.py +97 -0
  34. waldiez/exporting/chats/factory.py +65 -0
  35. waldiez/exporting/chats/processor.py +226 -0
  36. waldiez/exporting/chats/utils/__init__.py +6 -5
  37. waldiez/exporting/chats/utils/common.py +11 -45
  38. waldiez/exporting/chats/utils/group.py +55 -0
  39. waldiez/exporting/chats/utils/nested.py +37 -52
  40. waldiez/exporting/chats/utils/sequential.py +72 -61
  41. waldiez/exporting/chats/utils/{single_chat.py → single.py} +48 -50
  42. waldiez/exporting/core/__init__.py +196 -0
  43. waldiez/exporting/core/constants.py +17 -0
  44. waldiez/exporting/core/content.py +69 -0
  45. waldiez/exporting/core/context.py +244 -0
  46. waldiez/exporting/core/enums.py +89 -0
  47. waldiez/exporting/core/errors.py +19 -0
  48. waldiez/exporting/core/exporter.py +390 -0
  49. waldiez/exporting/core/exporters.py +67 -0
  50. waldiez/exporting/core/extras/__init__.py +39 -0
  51. waldiez/exporting/core/extras/agent_extras/__init__.py +27 -0
  52. waldiez/exporting/core/extras/agent_extras/captain_extras.py +57 -0
  53. waldiez/exporting/core/extras/agent_extras/group_manager_extras.py +102 -0
  54. waldiez/exporting/core/extras/agent_extras/rag_user_extras.py +53 -0
  55. waldiez/exporting/core/extras/agent_extras/reasoning_extras.py +68 -0
  56. waldiez/exporting/core/extras/agent_extras/standard_extras.py +263 -0
  57. waldiez/exporting/core/extras/base.py +241 -0
  58. waldiez/exporting/core/extras/chat_extras.py +118 -0
  59. waldiez/exporting/core/extras/flow_extras.py +70 -0
  60. waldiez/exporting/core/extras/model_extras.py +73 -0
  61. waldiez/exporting/core/extras/path_resolver.py +93 -0
  62. waldiez/exporting/core/extras/serializer.py +138 -0
  63. waldiez/exporting/core/extras/tool_extras.py +82 -0
  64. waldiez/exporting/core/protocols.py +259 -0
  65. waldiez/exporting/core/result.py +705 -0
  66. waldiez/exporting/core/types.py +329 -0
  67. waldiez/exporting/core/utils/__init__.py +11 -0
  68. waldiez/exporting/core/utils/comment.py +33 -0
  69. waldiez/exporting/core/utils/llm_config.py +117 -0
  70. waldiez/exporting/core/validation.py +96 -0
  71. waldiez/exporting/flow/__init__.py +6 -2
  72. waldiez/exporting/flow/execution_generator.py +193 -0
  73. waldiez/exporting/flow/exporter.py +107 -0
  74. waldiez/exporting/flow/factory.py +94 -0
  75. waldiez/exporting/flow/file_generator.py +214 -0
  76. waldiez/exporting/flow/merger.py +387 -0
  77. waldiez/exporting/flow/orchestrator.py +411 -0
  78. waldiez/exporting/flow/utils/__init__.py +9 -36
  79. waldiez/exporting/flow/utils/common.py +206 -0
  80. waldiez/exporting/flow/utils/importing.py +373 -0
  81. waldiez/exporting/flow/utils/linting.py +200 -0
  82. waldiez/exporting/flow/utils/{logging_utils.py → logging.py} +23 -9
  83. waldiez/exporting/models/__init__.py +3 -1
  84. waldiez/exporting/models/exporter.py +233 -0
  85. waldiez/exporting/models/factory.py +66 -0
  86. waldiez/exporting/models/processor.py +139 -0
  87. waldiez/exporting/tools/__init__.py +11 -0
  88. waldiez/exporting/tools/exporter.py +207 -0
  89. waldiez/exporting/tools/factory.py +57 -0
  90. waldiez/exporting/tools/processor.py +248 -0
  91. waldiez/exporting/tools/registration.py +133 -0
  92. waldiez/io/__init__.py +128 -0
  93. waldiez/io/_ws.py +199 -0
  94. waldiez/io/models/__init__.py +60 -0
  95. waldiez/io/models/base.py +66 -0
  96. waldiez/io/models/constants.py +78 -0
  97. waldiez/io/models/content/__init__.py +23 -0
  98. waldiez/io/models/content/audio.py +43 -0
  99. waldiez/io/models/content/base.py +45 -0
  100. waldiez/io/models/content/file.py +43 -0
  101. waldiez/io/models/content/image.py +96 -0
  102. waldiez/io/models/content/text.py +37 -0
  103. waldiez/io/models/content/video.py +43 -0
  104. waldiez/io/models/user_input.py +269 -0
  105. waldiez/io/models/user_response.py +215 -0
  106. waldiez/io/mqtt.py +681 -0
  107. waldiez/io/redis.py +782 -0
  108. waldiez/io/structured.py +419 -0
  109. waldiez/io/utils.py +184 -0
  110. waldiez/io/ws.py +298 -0
  111. waldiez/logger.py +481 -0
  112. waldiez/models/__init__.py +108 -51
  113. waldiez/models/agents/__init__.py +34 -70
  114. waldiez/models/agents/agent/__init__.py +10 -4
  115. waldiez/models/agents/agent/agent.py +466 -65
  116. waldiez/models/agents/agent/agent_data.py +119 -47
  117. waldiez/models/agents/agent/agent_type.py +13 -2
  118. waldiez/models/agents/agent/code_execution.py +12 -12
  119. waldiez/models/agents/agent/human_input_mode.py +8 -0
  120. waldiez/models/agents/agent/{linked_skill.py → linked_tool.py} +7 -7
  121. waldiez/models/agents/agent/nested_chat.py +35 -7
  122. waldiez/models/agents/agent/termination_message.py +30 -22
  123. waldiez/models/agents/{swarm_agent → agent}/update_system_message.py +22 -22
  124. waldiez/models/agents/agents.py +58 -63
  125. waldiez/models/agents/assistant/assistant.py +4 -4
  126. waldiez/models/agents/assistant/assistant_data.py +13 -1
  127. waldiez/models/agents/{captain_agent → captain}/captain_agent.py +5 -5
  128. waldiez/models/agents/{captain_agent → captain}/captain_agent_data.py +5 -5
  129. waldiez/models/agents/extra_requirements.py +11 -16
  130. waldiez/models/agents/group_manager/group_manager.py +103 -13
  131. waldiez/models/agents/group_manager/group_manager_data.py +36 -14
  132. waldiez/models/agents/group_manager/speakers.py +77 -24
  133. waldiez/models/agents/{rag_user → rag_user_proxy}/__init__.py +16 -16
  134. waldiez/models/agents/rag_user_proxy/rag_user_proxy.py +64 -0
  135. waldiez/models/agents/{rag_user/rag_user_data.py → rag_user_proxy/rag_user_proxy_data.py} +6 -5
  136. waldiez/models/agents/{rag_user → rag_user_proxy}/retrieve_config.py +182 -114
  137. waldiez/models/agents/{rag_user → rag_user_proxy}/vector_db_config.py +13 -13
  138. waldiez/models/agents/reasoning/reasoning_agent.py +6 -6
  139. waldiez/models/agents/reasoning/reasoning_agent_data.py +110 -63
  140. waldiez/models/agents/reasoning/reasoning_agent_reason_config.py +38 -10
  141. waldiez/models/agents/user_proxy/user_proxy.py +11 -7
  142. waldiez/models/agents/user_proxy/user_proxy_data.py +2 -2
  143. waldiez/models/chat/__init__.py +2 -1
  144. waldiez/models/chat/chat.py +166 -87
  145. waldiez/models/chat/chat_data.py +99 -136
  146. waldiez/models/chat/chat_message.py +33 -23
  147. waldiez/models/chat/chat_nested.py +31 -30
  148. waldiez/models/chat/chat_summary.py +10 -8
  149. waldiez/models/common/__init__.py +52 -2
  150. waldiez/models/common/ag2_version.py +1 -1
  151. waldiez/models/common/base.py +38 -7
  152. waldiez/models/common/dict_utils.py +42 -17
  153. waldiez/models/common/handoff.py +459 -0
  154. waldiez/models/common/id_generator.py +19 -0
  155. waldiez/models/common/method_utils.py +130 -68
  156. waldiez/{exporting/base/utils → models/common}/naming.py +38 -61
  157. waldiez/models/common/waldiez_version.py +37 -0
  158. waldiez/models/flow/__init__.py +9 -2
  159. waldiez/models/flow/connection.py +18 -0
  160. waldiez/models/flow/flow.py +311 -215
  161. waldiez/models/flow/flow_data.py +207 -40
  162. waldiez/models/flow/info.py +85 -0
  163. waldiez/models/flow/naming.py +131 -0
  164. waldiez/models/model/__init__.py +7 -1
  165. waldiez/models/model/extra_requirements.py +3 -12
  166. waldiez/models/model/model.py +76 -21
  167. waldiez/models/model/model_data.py +108 -20
  168. waldiez/models/tool/__init__.py +16 -0
  169. waldiez/models/tool/extra_requirements.py +36 -0
  170. waldiez/models/{skill/skill.py → tool/tool.py} +88 -88
  171. waldiez/models/tool/tool_data.py +51 -0
  172. waldiez/models/tool/tool_type.py +8 -0
  173. waldiez/models/waldiez.py +97 -80
  174. waldiez/runner.py +114 -49
  175. waldiez/running/__init__.py +1 -1
  176. waldiez/running/environment.py +49 -68
  177. waldiez/running/gen_seq_diagram.py +16 -14
  178. waldiez/running/running.py +53 -34
  179. waldiez/utils/__init__.py +0 -4
  180. waldiez/utils/cli_extras/jupyter.py +5 -3
  181. waldiez/utils/cli_extras/runner.py +6 -4
  182. waldiez/utils/cli_extras/studio.py +6 -4
  183. waldiez/utils/conflict_checker.py +15 -9
  184. waldiez/utils/flaml_warnings.py +5 -5
  185. {waldiez-0.4.6.dist-info → waldiez-0.4.8.dist-info}/METADATA +235 -91
  186. waldiez-0.4.8.dist-info/RECORD +200 -0
  187. waldiez/exporting/agent/agent_exporter.py +0 -297
  188. waldiez/exporting/agent/utils/__init__.py +0 -23
  189. waldiez/exporting/agent/utils/captain_agent.py +0 -263
  190. waldiez/exporting/agent/utils/code_execution.py +0 -65
  191. waldiez/exporting/agent/utils/group_manager.py +0 -220
  192. waldiez/exporting/agent/utils/rag_user/__init__.py +0 -7
  193. waldiez/exporting/agent/utils/rag_user/rag_user.py +0 -209
  194. waldiez/exporting/agent/utils/reasoning.py +0 -36
  195. waldiez/exporting/agent/utils/swarm_agent.py +0 -469
  196. waldiez/exporting/agent/utils/teachability.py +0 -41
  197. waldiez/exporting/agent/utils/termination_message.py +0 -44
  198. waldiez/exporting/base/__init__.py +0 -25
  199. waldiez/exporting/base/agent_position.py +0 -75
  200. waldiez/exporting/base/base_exporter.py +0 -118
  201. waldiez/exporting/base/export_position.py +0 -48
  202. waldiez/exporting/base/import_position.py +0 -23
  203. waldiez/exporting/base/mixin.py +0 -137
  204. waldiez/exporting/base/utils/__init__.py +0 -18
  205. waldiez/exporting/base/utils/comments.py +0 -96
  206. waldiez/exporting/base/utils/path_check.py +0 -68
  207. waldiez/exporting/base/utils/to_string.py +0 -84
  208. waldiez/exporting/chats/chats_exporter.py +0 -240
  209. waldiez/exporting/chats/utils/swarm.py +0 -210
  210. waldiez/exporting/flow/flow_exporter.py +0 -528
  211. waldiez/exporting/flow/utils/agent_utils.py +0 -204
  212. waldiez/exporting/flow/utils/chat_utils.py +0 -71
  213. waldiez/exporting/flow/utils/def_main.py +0 -77
  214. waldiez/exporting/flow/utils/flow_content.py +0 -202
  215. waldiez/exporting/flow/utils/flow_names.py +0 -116
  216. waldiez/exporting/flow/utils/importing_utils.py +0 -227
  217. waldiez/exporting/models/models_exporter.py +0 -199
  218. waldiez/exporting/models/utils.py +0 -174
  219. waldiez/exporting/skills/__init__.py +0 -9
  220. waldiez/exporting/skills/skills_exporter.py +0 -176
  221. waldiez/exporting/skills/utils.py +0 -369
  222. waldiez/models/agents/agent/teachability.py +0 -70
  223. waldiez/models/agents/rag_user/rag_user.py +0 -60
  224. waldiez/models/agents/swarm_agent/__init__.py +0 -50
  225. waldiez/models/agents/swarm_agent/after_work.py +0 -179
  226. waldiez/models/agents/swarm_agent/on_condition.py +0 -105
  227. waldiez/models/agents/swarm_agent/on_condition_available.py +0 -142
  228. waldiez/models/agents/swarm_agent/on_condition_target.py +0 -40
  229. waldiez/models/agents/swarm_agent/swarm_agent.py +0 -107
  230. waldiez/models/agents/swarm_agent/swarm_agent_data.py +0 -124
  231. waldiez/models/flow/utils.py +0 -232
  232. waldiez/models/skill/__init__.py +0 -16
  233. waldiez/models/skill/extra_requirements.py +0 -36
  234. waldiez/models/skill/skill_data.py +0 -53
  235. waldiez/models/skill/skill_type.py +0 -8
  236. waldiez/utils/pysqlite3_checker.py +0 -308
  237. waldiez/utils/rdps_checker.py +0 -122
  238. waldiez-0.4.6.dist-info/RECORD +0 -149
  239. /waldiez/models/agents/{captain_agent → captain}/__init__.py +0 -0
  240. /waldiez/models/agents/{captain_agent → captain}/captain_agent_lib_entry.py +0 -0
  241. {waldiez-0.4.6.dist-info → waldiez-0.4.8.dist-info}/WHEEL +0 -0
  242. {waldiez-0.4.6.dist-info → waldiez-0.4.8.dist-info}/entry_points.txt +0 -0
  243. {waldiez-0.4.6.dist-info → waldiez-0.4.8.dist-info}/licenses/LICENSE +0 -0
  244. {waldiez-0.4.6.dist-info → waldiez-0.4.8.dist-info}/licenses/NOTICE.md +0 -0
@@ -2,20 +2,23 @@
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
3
  """Common data structures for agents."""
4
4
 
5
- from typing import List, Optional, Union
5
+ from typing import Any, Optional, Union
6
6
 
7
- from pydantic import ConfigDict, Field
7
+ from pydantic import ConfigDict, Field, model_validator
8
8
  from pydantic.alias_generators import to_camel
9
- from typing_extensions import Annotated, Literal
9
+ from typing_extensions import Annotated, Literal, Self
10
10
 
11
- from ...common import WaldiezBase
11
+ from ...common import WaldiezBase, WaldiezTransitionTarget, update_dict
12
12
  from .code_execution import WaldiezAgentCodeExecutionConfig
13
- from .linked_skill import WaldiezAgentLinkedSkill
13
+ from .human_input_mode import WaldiezAgentHumanInputMode
14
+ from .linked_tool import WaldiezAgentLinkedTool
14
15
  from .nested_chat import WaldiezAgentNestedChat
15
- from .teachability import WaldiezAgentTeachability
16
16
  from .termination_message import WaldiezAgentTerminationMessage
17
+ from .update_system_message import WaldiezAgentUpdateSystemMessage
17
18
 
18
19
 
20
+ # noqa: E501
21
+ # pylint: disable=line-too-long
19
22
  class WaldiezAgentData(WaldiezBase):
20
23
  """Waldiez Agent Data.
21
24
 
@@ -34,16 +37,24 @@ class WaldiezAgentData(WaldiezBase):
34
37
  before ending the chat. Default: None (no limit).
35
38
  termination : WaldiezAgentTerminationMessage
36
39
  The message termination check to use (keyword, method, none)
37
- teachability : WaldiezAgentTeachability
38
- The agent teachability configuration.
39
40
  model_ids: List[str]
40
- A list of models (their ids) to link with the agent.
41
- skills : List[WaldiezAgentLinkedSkill]
42
- A list of skills (id and executor) to register.
43
- nested_chats : List[WaldiezAgentNestedChat]
41
+ The ids of the models to link with the agent.
42
+ tools : list[WaldiezAgentLinkedTool]
43
+ A list of tools (id and executor) to register.
44
+ nested_chats : list[WaldiezAgentNestedChat]
44
45
  A list of nested chats (triggered_by, messages), to register.
45
- is_multimodal: bool
46
- A flag to indicate if the agent is multimodal.
46
+ context_variables : Optional[dict[str, Any]]
47
+ Context variables that provide a persistent context
48
+ for the agent. Note: This will be a reference to a shared
49
+ context for multi-agent chats. Behaves like a dictionary
50
+ with keys and values (akin to dict[str, Any]).
51
+ update_agent_state_before_reply : list[str |WaldiezAgentUpdateSystemMessage]
52
+ A list of functions, including UpdateSystemMessage,
53
+ called to update the agent's state before it replies.
54
+ Each function is called when the agent is selected
55
+ and before it speaks.
56
+ handoffs : list[WaldiezAgentHandoff]
57
+ A list of handoffs (conditions, targets) to register.
47
58
  """
48
59
 
49
60
  model_config = ConfigDict(
@@ -63,16 +74,16 @@ class WaldiezAgentData(WaldiezBase):
63
74
  description="The agent's system message.",
64
75
  alias="systemMessage",
65
76
  ),
66
- ]
77
+ ] = None
67
78
  human_input_mode: Annotated[
68
- Literal["ALWAYS", "NEVER", "TERMINATE"],
79
+ WaldiezAgentHumanInputMode,
69
80
  Field(
70
81
  "NEVER",
71
82
  title="Human input mode",
72
83
  description="The human input mode to use for the agent.",
73
84
  alias="humanInputMode",
74
85
  ),
75
- ]
86
+ ] = "NEVER"
76
87
  code_execution_config: Annotated[
77
88
  Union[WaldiezAgentCodeExecutionConfig, Literal[False]],
78
89
  Field(
@@ -84,7 +95,7 @@ class WaldiezAgentData(WaldiezBase):
84
95
  ),
85
96
  alias="codeExecutionConfig",
86
97
  ),
87
- ]
98
+ ] = False
88
99
  agent_default_auto_reply: Annotated[
89
100
  Optional[str],
90
101
  Field(
@@ -95,7 +106,7 @@ class WaldiezAgentData(WaldiezBase):
95
106
  ),
96
107
  alias="agentDefaultAutoReply",
97
108
  ),
98
- ]
109
+ ] = None
99
110
  max_consecutive_auto_reply: Annotated[
100
111
  Optional[int],
101
112
  Field(
@@ -107,7 +118,7 @@ class WaldiezAgentData(WaldiezBase):
107
118
  ),
108
119
  alias="maxConsecutiveAutoReply",
109
120
  ),
110
- ]
121
+ ] = None
111
122
  termination: Annotated[
112
123
  WaldiezAgentTerminationMessage,
113
124
  Field(
@@ -118,47 +129,108 @@ class WaldiezAgentData(WaldiezBase):
118
129
  default_factory=WaldiezAgentTerminationMessage,
119
130
  ),
120
131
  ]
121
- teachability: Annotated[
122
- Optional[WaldiezAgentTeachability],
123
- Field(
124
- title="Teachability",
125
- description="The agent teachability configuration.",
126
- default_factory=WaldiezAgentTeachability,
127
- ),
128
- ]
129
132
  model_ids: Annotated[
130
- List[str],
133
+ list[str],
131
134
  Field(
132
135
  default_factory=list,
133
- title="Model IDs",
134
- description="A list of models (their ids) to link with the agent.",
136
+ title="Model ID",
137
+ description=(
138
+ "The id of the model to link with the agent. "
139
+ "This is a reference to a model in the models registry."
140
+ ),
135
141
  alias="modelIds",
136
142
  ),
137
- ]
138
- skills: Annotated[
139
- List[WaldiezAgentLinkedSkill],
143
+ ] = []
144
+ tools: Annotated[
145
+ list[WaldiezAgentLinkedTool],
140
146
  Field(
141
147
  default_factory=list,
142
- title="Skills",
143
- description=("A list of skills (id and executor) to register."),
148
+ title="Tools",
149
+ description=("A list of tools (id and executor) to register."),
144
150
  ),
145
- ]
151
+ ] = []
146
152
  nested_chats: Annotated[
147
- List[WaldiezAgentNestedChat],
153
+ list[WaldiezAgentNestedChat],
148
154
  Field(
149
155
  default_factory=list,
150
156
  description=(
151
- "A list of nested chats (triggered_by, messages), to register."
157
+ "A list of nested chats (triggers, messages, ...), to register."
152
158
  ),
153
159
  alias="nestedChats",
154
160
  ),
155
- ]
156
- is_multimodal: Annotated[
157
- bool,
161
+ ] = []
162
+ context_variables: Annotated[
163
+ dict[str, Any],
158
164
  Field(
159
- False,
160
- title="Is multimodal",
161
- description="A flag to indicate if the agent is multimodal.",
162
- alias="isMultimodal",
165
+ default_factory=dict, # pyright: ignore
166
+ title="Context variables",
167
+ description=(
168
+ "Context variables that provide a persistent context "
169
+ "for the agent. Note: This will be a reference to a shared "
170
+ "context for multi-agent chats. Behaves like a dictionary "
171
+ "with keys and values (akin to dict[str, Any])."
172
+ ),
173
+ alias="contextVariables",
163
174
  ),
164
- ] = False
175
+ ] = {}
176
+
177
+ update_agent_state_before_reply: Annotated[
178
+ list[Union[str, WaldiezAgentUpdateSystemMessage]],
179
+ Field(
180
+ title="Update Agent State Before Reply",
181
+ alias="updateAgentStateBeforeReply",
182
+ description=(
183
+ "A list of functions, including UpdateSystemMessage,"
184
+ "called to update the agent's state before it replies. "
185
+ " Each function is called when the agent is selected "
186
+ "and before it speaks. If not an UpdateSystemMessage, "
187
+ "it should be a skill id."
188
+ ),
189
+ default_factory=list,
190
+ ),
191
+ ] = []
192
+ handoffs: Annotated[
193
+ list[str],
194
+ Field(
195
+ default_factory=list,
196
+ title="Handoffs",
197
+ description=("A list of handoffs (target ids) to register."),
198
+ ),
199
+ ] = []
200
+ after_work: Annotated[
201
+ Optional[WaldiezTransitionTarget],
202
+ Field(
203
+ None,
204
+ title="After work",
205
+ description=(
206
+ "The target to transfer control to after the agent"
207
+ " has finished its work. (used if in a group chat)"
208
+ ),
209
+ alias="afterWork",
210
+ ),
211
+ ] = None
212
+
213
+ parent_id: Annotated[
214
+ Optional[str],
215
+ Field(
216
+ None,
217
+ title="Parent ID",
218
+ description=(
219
+ "The id of the parent agent. This is used for group chats."
220
+ ),
221
+ alias="parentId",
222
+ ),
223
+ ] = None
224
+
225
+ @model_validator(mode="after")
226
+ def update_context_variables(self) -> Self:
227
+ """Update the context variables.
228
+
229
+ Returns
230
+ -------
231
+ Self
232
+ The updated instance of the class.
233
+ """
234
+ context_vars = update_dict(self.context_variables)
235
+ self.context_variables = context_vars
236
+ return self
@@ -6,6 +6,17 @@ from typing_extensions import Literal
6
6
 
7
7
  # pylint: disable=line-too-long
8
8
  # fmt: off
9
- WaldiezAgentType = Literal["user", "assistant", "manager", "rag_user", "swarm", "reasoning", "captain"] # noqa: E501
10
- """Possible types of a Waldiez Agent: user, assistant, manager, rag_user, swarm, reasoning, captain.""" # noqa: E501
9
+ WaldiezAgentType = Literal["user_proxy", "assistant", "group_manager", "manager", "rag_user", "swarm", "reasoning", "captain", "user", "rag_user_proxy"] # noqa: E501
10
+ """Possible types of a Waldiez Agent:
11
+ - user_proxy,
12
+ - assistant,
13
+ - group_manager,
14
+ - rag_user_proxy,
15
+ - reasoning,
16
+ - captain,
17
+ - swarm (deprecated: do not use it),
18
+ - user (deprecated: use user_proxy)
19
+ - rag_user (deprecated: user rag_user_proxy)
20
+ - manager (deprecated: use group_manager)
21
+ """ # noqa: W291
11
22
  # fmt: on
@@ -2,7 +2,7 @@
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
3
  """Waldiez Agent Code Execution Configuration."""
4
4
 
5
- from typing import List, Optional
5
+ from typing import Optional
6
6
 
7
7
  from pydantic import Field
8
8
  from typing_extensions import Annotated
@@ -23,51 +23,51 @@ class WaldiezAgentCodeExecutionConfig(WaldiezBase):
23
23
  The timeout for the code execution. By default None (no timeout).
24
24
  last_n_messages : Optional[int]
25
25
  The chat's last n messages to consider for the code execution.
26
- functions : Optional[List[str]]
26
+ functions : Optional[list[str]]
27
27
  If not using docker, a list of function ids to use.
28
28
  """
29
29
 
30
30
  work_dir: Annotated[
31
31
  Optional[str],
32
32
  Field(
33
- None,
33
+ default=None,
34
34
  title="Working directory",
35
35
  description="The working directory for the code execution.",
36
36
  alias="workDir",
37
37
  ),
38
- ]
38
+ ] = None
39
39
  use_docker: Annotated[
40
40
  Optional[bool],
41
41
  Field(
42
- None,
42
+ default=None,
43
43
  title="Use docker",
44
44
  description="Run the code in a docker container.",
45
45
  alias="useDocker",
46
46
  ),
47
- ]
47
+ ] = None
48
48
  timeout: Annotated[
49
49
  Optional[float],
50
50
  Field(
51
- None,
51
+ default=None,
52
52
  title="Timeout",
53
53
  description=(
54
54
  "The timeout for the code execution.Default: No timeout"
55
55
  ),
56
56
  ),
57
- ]
57
+ ] = None
58
58
  last_n_messages: Annotated[
59
59
  Optional[int],
60
60
  Field(
61
- None,
61
+ default=None,
62
62
  title="Last N Messages",
63
63
  description="The number of previous messages in the chat to use.",
64
64
  ),
65
- ]
65
+ ] = None
66
66
  functions: Annotated[
67
- List[str],
67
+ list[str],
68
68
  Field(
69
69
  default_factory=list,
70
70
  title="Functions",
71
71
  description="If not using docker, the function ids to use",
72
72
  ),
73
- ]
73
+ ] = []
@@ -0,0 +1,8 @@
1
+ # SPDX-License-Identifier: Apache-2.0.
2
+ # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+ """Waldiez Agent human input modes."""
4
+
5
+ from typing_extensions import Literal
6
+
7
+ WaldiezAgentHumanInputMode = Literal["ALWAYS", "NEVER", "TERMINATE"]
8
+ """Possible human input modes for agents: ALWAYS, NEVER, TERMINATE."""
@@ -1,6 +1,6 @@
1
1
  # SPDX-License-Identifier: Apache-2.0.
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
- """Waldiez Agent Skill Model."""
3
+ """Waldiez Agent Tool Model."""
4
4
 
5
5
  from pydantic import Field
6
6
  from typing_extensions import Annotated
@@ -8,25 +8,25 @@ from typing_extensions import Annotated
8
8
  from ...common import WaldiezBase
9
9
 
10
10
 
11
- class WaldiezAgentLinkedSkill(WaldiezBase):
12
- """Waldiez Agent Linked Skill.
11
+ class WaldiezAgentLinkedTool(WaldiezBase):
12
+ """Waldiez Agent Linked Tool.
13
13
 
14
14
  Attributes
15
15
  ----------
16
16
  id : str
17
- The id of the skill to use.
17
+ The id of the tool to use.
18
18
  executor_id: str
19
- The id of the agent to use that skill.
19
+ The id of the agent to use that tool.
20
20
  """
21
21
 
22
22
  id: Annotated[
23
- str, Field(..., title="ID", description="The id of the skill to use.")
23
+ str, Field(..., title="ID", description="The id of the tool to use.")
24
24
  ]
25
25
  executor_id: Annotated[
26
26
  str,
27
27
  Field(
28
28
  ...,
29
29
  title="Executor ID",
30
- description="The id of the agent to use that skill.",
30
+ description="The id of the agent to use that tool.",
31
31
  ),
32
32
  ]
@@ -2,12 +2,15 @@
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
3
  """Waldiez Agent Nested Chat."""
4
4
 
5
- from typing import List
6
-
7
5
  from pydantic import Field
8
6
  from typing_extensions import Annotated
9
7
 
10
- from ...common import WaldiezBase
8
+ from ...common import (
9
+ WaldiezBase,
10
+ WaldiezDefaultCondition,
11
+ WaldiezHandoffCondition,
12
+ WaldiezTransitionAvailability,
13
+ )
11
14
 
12
15
 
13
16
  class WaldiezAgentNestedChatMessage(WaldiezBase):
@@ -42,15 +45,18 @@ class WaldiezAgentNestedChat(WaldiezBase):
42
45
 
43
46
  Attributes
44
47
  ----------
45
- triggered_by : List[str]
48
+ triggered_by : list[str]
46
49
  A list of agent ids that trigger the nested chat.
47
- messages : List[WaldiezAgentNestedChatMessage]
50
+ messages : list[WaldiezAgentNestedChatMessage]
48
51
  The list of messages (chat ids and 'is_reply'z)
49
52
  to include the in the nested chat registration.
53
+ order : int
54
+ The order of the nested chat (if used as a handoff).
55
+ Defaults to 0.
50
56
  """
51
57
 
52
58
  triggered_by: Annotated[
53
- List[str],
59
+ list[str],
54
60
  Field(
55
61
  title="Triggered By",
56
62
  description=("A list of agent ids that trigger the nested chat."),
@@ -59,7 +65,7 @@ class WaldiezAgentNestedChat(WaldiezBase):
59
65
  ),
60
66
  ]
61
67
  messages: Annotated[
62
- List[WaldiezAgentNestedChatMessage],
68
+ list[WaldiezAgentNestedChatMessage],
63
69
  Field(
64
70
  title="Messages",
65
71
  description=(
@@ -69,3 +75,25 @@ class WaldiezAgentNestedChat(WaldiezBase):
69
75
  default_factory=list,
70
76
  ),
71
77
  ]
78
+ condition: Annotated[
79
+ WaldiezHandoffCondition,
80
+ Field(
81
+ default_factory=WaldiezDefaultCondition.create,
82
+ title="Condition",
83
+ description=(
84
+ "The condition to use for the nested chat handoff. "
85
+ "If not provided, the nested chat will always be available."
86
+ ),
87
+ ),
88
+ ]
89
+ available: Annotated[
90
+ WaldiezTransitionAvailability,
91
+ Field(
92
+ default_factory=WaldiezTransitionAvailability,
93
+ title="Available",
94
+ description=(
95
+ "The availability of the nested chat. "
96
+ "If not provided, the nested chat will always be available."
97
+ ),
98
+ ),
99
+ ]
@@ -2,7 +2,7 @@
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
3
  """Waldiez Agent Termination Message Check."""
4
4
 
5
- from typing import List, Optional, Tuple
5
+ from typing import Optional
6
6
 
7
7
  from pydantic import Field, model_validator
8
8
  from typing_extensions import Annotated, Literal, Self
@@ -12,7 +12,7 @@ from ...common import WaldiezBase, check_function, generate_function
12
12
  IS_TERMINATION_MESSAGE = "is_termination_message"
13
13
  IS_TERMINATION_MESSAGE_ARGS = ["message"]
14
14
  IS_TERMINATION_MESSAGE_TYPES = (
15
- ["Dict[str, Any]"],
15
+ ["dict[str, Any]"],
16
16
  "bool",
17
17
  )
18
18
 
@@ -24,7 +24,7 @@ class WaldiezAgentTerminationMessage(WaldiezBase):
24
24
  ----------
25
25
  type : Literal["none", "keyword", "method"]
26
26
  The type of the termination check to use: "none", "keyword", "method"
27
- keywords : List[str]
27
+ keywords : list[str]
28
28
  If the type is "keyword", the keywords to search in the message.
29
29
  criterion : Optional[Literal["found", "ending", "exact"]] = None
30
30
  If the type is "keyword", the criterion to use (e.g.: in, endswith, ==)
@@ -52,9 +52,9 @@ class WaldiezAgentTerminationMessage(WaldiezBase):
52
52
  "none, keyword, method"
53
53
  ),
54
54
  ),
55
- ]
55
+ ] = "none"
56
56
  keywords: Annotated[
57
- List[str],
57
+ list[str],
58
58
  Field(
59
59
  default_factory=list,
60
60
  title="Keywords",
@@ -63,9 +63,9 @@ class WaldiezAgentTerminationMessage(WaldiezBase):
63
63
  " the keywords to search in the message."
64
64
  ),
65
65
  ),
66
- ]
66
+ ] = []
67
67
  criterion: Annotated[
68
- Optional[Literal["found", "ending", "exact"]],
68
+ Optional[Literal["found", "ending", "starting", "exact"]],
69
69
  Field(
70
70
  "exact",
71
71
  title="Criterion",
@@ -74,7 +74,7 @@ class WaldiezAgentTerminationMessage(WaldiezBase):
74
74
  "the criterion to use (e.g.: in, endswith, ==)"
75
75
  ),
76
76
  ),
77
- ]
77
+ ] = "exact"
78
78
  method_content: Annotated[
79
79
  Optional[str],
80
80
  Field(
@@ -87,7 +87,7 @@ class WaldiezAgentTerminationMessage(WaldiezBase):
87
87
  "bool (whether the message is a termination message or not.)"
88
88
  ),
89
89
  ),
90
- ]
90
+ ] = None
91
91
 
92
92
  _string: str = "None"
93
93
 
@@ -95,7 +95,7 @@ class WaldiezAgentTerminationMessage(WaldiezBase):
95
95
  self,
96
96
  name_prefix: Optional[str] = None,
97
97
  name_suffix: Optional[str] = None,
98
- ) -> Tuple[str, str]:
98
+ ) -> tuple[str, str]:
99
99
  """Get the termination function.
100
100
 
101
101
  Parameters
@@ -107,7 +107,7 @@ class WaldiezAgentTerminationMessage(WaldiezBase):
107
107
 
108
108
  Returns
109
109
  -------
110
- Tuple[str, str]
110
+ tuple[str, str]
111
111
  The termination function and the function name.
112
112
  """
113
113
  function_name = "is_termination_message"
@@ -162,26 +162,34 @@ class WaldiezAgentTerminationMessage(WaldiezBase):
162
162
  """Validate the keyword termination configuration."""
163
163
  if not self.keywords:
164
164
  raise ValueError("Keywords are required for keyword termination.")
165
- if self.criterion not in ["found", "ending", "exact"]:
165
+ if self.criterion not in ["found", "ending", "starting", "exact"]:
166
166
  raise ValueError(f"Invalid criterion: {self.criterion}")
167
167
  # pylint: disable=inconsistent-quotes
168
168
  keywords_str = ", ".join([f'"{keyword}"' for keyword in self.keywords])
169
+ common_start = (
170
+ "lambda x: any(isinstance(x, dict) and "
171
+ 'x.get("content", "") and '
172
+ 'isinstance(x.get("content", ""), str) and '
173
+ )
174
+ common_end = f"for keyword in [{keywords_str}])"
169
175
  if self.criterion == "found":
170
176
  self._string = (
171
- 'lambda x: any(x.get("content", "") and '
172
- 'keyword in x.get("content", "") '
173
- f"for keyword in [{keywords_str}])"
177
+ f'{common_start}keyword in x.get("content", "") {common_end}'
178
+ )
179
+ elif self.criterion == "ending":
180
+ self._string = (
181
+ f'{common_start}x.get("content", "").endswith(keyword) '
182
+ f"{common_end}"
174
183
  )
175
- if self.criterion == "ending":
184
+ elif self.criterion == "starting":
176
185
  self._string = (
177
- 'lambda x: any(x.get("content", "") and '
178
- 'x.get("content", "").endswith(keyword) '
179
- f"for keyword in [{keywords_str}])"
186
+ f'{common_start}x.get("content", "").startswith(keyword) '
187
+ f"{common_end}"
180
188
  )
181
- if self.criterion == "exact":
189
+
190
+ elif self.criterion == "exact": # pragma: no branch
182
191
  self._string = (
183
- 'lambda x: any(x.get("content", "") == keyword '
184
- f"for keyword in [{keywords_str}])"
192
+ f'{common_start}x.get("content", "") == keyword {common_end}'
185
193
  )
186
194
 
187
195
  @model_validator(mode="after")