swarms 7.7.5__tar.gz → 7.7.7__tar.gz

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.
Files changed (188) hide show
  1. {swarms-7.7.5 → swarms-7.7.7}/PKG-INFO +1 -1
  2. {swarms-7.7.5 → swarms-7.7.7}/pyproject.toml +2 -2
  3. {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/__init__.py +0 -1
  4. {swarms-7.7.5 → swarms-7.7.7}/swarms/communication/duckdb_wrap.py +15 -6
  5. swarms-7.7.7/swarms/prompts/max_loop_prompt.py +48 -0
  6. swarms-7.7.7/swarms/prompts/react_base_prompt.py +41 -0
  7. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/agent.py +70 -109
  8. swarms-7.7.7/swarms/structs/concurrent_workflow.py +534 -0
  9. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/conversation.py +123 -6
  10. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/groupchat.py +0 -12
  11. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/multi_model_gpu_manager.py +0 -1
  12. swarms-7.7.5/swarms/structs/concurrent_workflow.py +0 -419
  13. {swarms-7.7.5 → swarms-7.7.7}/LICENSE +0 -0
  14. {swarms-7.7.5 → swarms-7.7.7}/README.md +0 -0
  15. {swarms-7.7.5 → swarms-7.7.7}/swarms/__init__.py +0 -0
  16. {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/agent_judge.py +0 -0
  17. {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/agent_print.py +0 -0
  18. {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/ape_agent.py +0 -0
  19. {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/auto_generate_swarm_config.py +0 -0
  20. {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/consistency_agent.py +0 -0
  21. {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/create_agents_from_yaml.py +0 -0
  22. {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/flexion_agent.py +0 -0
  23. {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/gkp_agent.py +0 -0
  24. {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/i_agent.py +0 -0
  25. {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/openai_assistant.py +0 -0
  26. {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/reasoning_agents.py +0 -0
  27. {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/reasoning_duo.py +0 -0
  28. {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/tool_agent.py +0 -0
  29. {swarms-7.7.5 → swarms-7.7.7}/swarms/artifacts/__init__.py +0 -0
  30. {swarms-7.7.5 → swarms-7.7.7}/swarms/artifacts/main_artifact.py +0 -0
  31. {swarms-7.7.5 → swarms-7.7.7}/swarms/cli/__init__.py +0 -0
  32. {swarms-7.7.5 → swarms-7.7.7}/swarms/cli/create_agent.py +0 -0
  33. {swarms-7.7.5 → swarms-7.7.7}/swarms/cli/main.py +0 -0
  34. {swarms-7.7.5 → swarms-7.7.7}/swarms/cli/onboarding_process.py +0 -0
  35. {swarms-7.7.5 → swarms-7.7.7}/swarms/client/__init__.py +0 -0
  36. {swarms-7.7.5 → swarms-7.7.7}/swarms/client/main.py +0 -0
  37. {swarms-7.7.5 → swarms-7.7.7}/swarms/communication/__init__.py +0 -0
  38. {swarms-7.7.5 → swarms-7.7.7}/swarms/communication/sqlite_wrap.py +0 -0
  39. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/__init__.py +0 -0
  40. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/accountant_swarm_prompts.py +0 -0
  41. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/ag_prompt.py +0 -0
  42. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/aga.py +0 -0
  43. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/agent_judge_prompt.py +0 -0
  44. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/agent_prompt.py +0 -0
  45. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/agent_prompts.py +0 -0
  46. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/agent_system_prompts.py +0 -0
  47. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/ai_research_team.py +0 -0
  48. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/aot_prompt.py +0 -0
  49. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/autobloggen.py +0 -0
  50. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/autoswarm.py +0 -0
  51. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/chat_prompt.py +0 -0
  52. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/code_interpreter.py +0 -0
  53. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/code_spawner.py +0 -0
  54. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/debate.py +0 -0
  55. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/documentation.py +0 -0
  56. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/education.py +0 -0
  57. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/finance_agent_prompt.py +0 -0
  58. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/finance_agent_sys_prompt.py +0 -0
  59. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/growth_agent_prompt.py +0 -0
  60. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/idea2img.py +0 -0
  61. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/legal_agent_prompt.py +0 -0
  62. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/logistics.py +0 -0
  63. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/meta_system_prompt.py +0 -0
  64. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/multi_agent_collab_prompt.py +0 -0
  65. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/multi_modal_autonomous_instruction_prompt.py +0 -0
  66. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/multi_modal_prompts.py +0 -0
  67. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/multi_modal_visual_prompts.py +0 -0
  68. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/operations_agent_prompt.py +0 -0
  69. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/paper_idea_agent.py +0 -0
  70. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/personal_stylist.py +0 -0
  71. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/product_agent_prompt.py +0 -0
  72. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/programming.py +0 -0
  73. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/project_manager.py +0 -0
  74. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/prompt.py +0 -0
  75. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/prompt_generator.py +0 -0
  76. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/prompt_generator_optimizer.py +0 -0
  77. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/python.py +0 -0
  78. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/react.py +0 -0
  79. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/reasoning_prompt.py +0 -0
  80. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/refiner_agent_prompt.py +0 -0
  81. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/sales.py +0 -0
  82. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/sales_prompts.py +0 -0
  83. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/security_team.py +0 -0
  84. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/self_operating_prompt.py +0 -0
  85. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/sop_generator_agent_prompt.py +0 -0
  86. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/summaries_prompts.py +0 -0
  87. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/support_agent_prompt.py +0 -0
  88. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/swarm_manager_agent.py +0 -0
  89. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/task_assignment_prompt.py +0 -0
  90. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/tests.py +0 -0
  91. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/tools.py +0 -0
  92. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/urban_planning.py +0 -0
  93. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/visual_cot.py +0 -0
  94. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/worker_prompt.py +0 -0
  95. {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/xray_swarm_prompt.py +0 -0
  96. {swarms-7.7.5 → swarms-7.7.7}/swarms/schemas/__init__.py +0 -0
  97. {swarms-7.7.5 → swarms-7.7.7}/swarms/schemas/agent_step_schemas.py +0 -0
  98. {swarms-7.7.5 → swarms-7.7.7}/swarms/schemas/base_schemas.py +0 -0
  99. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/__init__.py +0 -0
  100. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/agent_builder.py +0 -0
  101. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/agent_registry.py +0 -0
  102. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/agent_roles.py +0 -0
  103. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/agent_router.py +0 -0
  104. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/aop.py +0 -0
  105. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/auto_swarm_builder.py +0 -0
  106. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/base_structure.py +0 -0
  107. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/base_swarm.py +0 -0
  108. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/base_workflow.py +0 -0
  109. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/concat.py +0 -0
  110. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/csv_to_agent.py +0 -0
  111. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/de_hallucination_swarm.py +0 -0
  112. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/deep_research_swarm.py +0 -0
  113. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/dynamic_conversational_swarm.py +0 -0
  114. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/graph_workflow.py +0 -0
  115. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/hiearchical_swarm.py +0 -0
  116. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/hybrid_hiearchical_peer_swarm.py +0 -0
  117. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/ma_utils.py +0 -0
  118. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/majority_voting.py +0 -0
  119. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/malt.py +0 -0
  120. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/matrix_swarm.py +0 -0
  121. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/meme_agent_persona_generator.py +0 -0
  122. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/mixture_of_agents.py +0 -0
  123. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/model_router.py +0 -0
  124. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/multi_agent_collab.py +0 -0
  125. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/multi_agent_exec.py +0 -0
  126. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/multi_agent_router.py +0 -0
  127. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/omni_agent_types.py +0 -0
  128. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/output_types.py +0 -0
  129. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/rearrange.py +0 -0
  130. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/round_robin.py +0 -0
  131. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/safe_loading.py +0 -0
  132. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/sequential_workflow.py +0 -0
  133. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/spreadsheet_swarm.py +0 -0
  134. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/stopping_conditions.py +0 -0
  135. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/swarm_arange.py +0 -0
  136. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/swarm_eval.py +0 -0
  137. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/swarm_id_generator.py +0 -0
  138. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/swarm_matcher.py +0 -0
  139. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/swarm_registry.py +0 -0
  140. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/swarm_router.py +0 -0
  141. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/swarming_architectures.py +0 -0
  142. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/tree_swarm.py +0 -0
  143. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/utils.py +0 -0
  144. {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/various_alt_swarms.py +0 -0
  145. {swarms-7.7.5 → swarms-7.7.7}/swarms/telemetry/__init__.py +0 -0
  146. {swarms-7.7.5 → swarms-7.7.7}/swarms/telemetry/bootup.py +0 -0
  147. {swarms-7.7.5 → swarms-7.7.7}/swarms/telemetry/main.py +0 -0
  148. {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/__init__.py +0 -0
  149. {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/base_tool.py +0 -0
  150. {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/cohere_func_call_schema.py +0 -0
  151. {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/func_calling_utils.py +0 -0
  152. {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/func_to_str.py +0 -0
  153. {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/function_util.py +0 -0
  154. {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/json_former.py +0 -0
  155. {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/json_utils.py +0 -0
  156. {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/logits_processor.py +0 -0
  157. {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/mcp_client.py +0 -0
  158. {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/mcp_integration.py +0 -0
  159. {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/openai_func_calling_schema_pydantic.py +0 -0
  160. {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/openai_tool_creator_decorator.py +0 -0
  161. {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/py_func_to_openai_func_str.py +0 -0
  162. {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/pydantic_to_json.py +0 -0
  163. {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/tool_parse_exec.py +0 -0
  164. {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/tool_registry.py +0 -0
  165. {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/tool_schema_base_model.py +0 -0
  166. {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/tool_utils.py +0 -0
  167. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/__init__.py +0 -0
  168. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/any_to_str.py +0 -0
  169. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/auto_download_check_packages.py +0 -0
  170. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/calculate_func_metrics.py +0 -0
  171. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/data_to_text.py +0 -0
  172. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/disable_logging.py +0 -0
  173. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/file_processing.py +0 -0
  174. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/formatter.py +0 -0
  175. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/function_caller_model.py +0 -0
  176. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/generate_keys.py +0 -0
  177. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/history_output_formatter.py +0 -0
  178. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/litellm_tokenizer.py +0 -0
  179. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/litellm_wrapper.py +0 -0
  180. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/loguru_logger.py +0 -0
  181. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/markdown_message.py +0 -0
  182. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/parse_code.py +0 -0
  183. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/pdf_to_text.py +0 -0
  184. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/str_to_dict.py +0 -0
  185. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/try_except_wrapper.py +0 -0
  186. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/visualizer.py +0 -0
  187. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/vllm_wrapper.py +0 -0
  188. {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/wrapper_clusterop.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: swarms
3
- Version: 7.7.5
3
+ Version: 7.7.7
4
4
  Summary: Swarms - TGSC
5
5
  Home-page: https://github.com/kyegomez/swarms
6
6
  License: MIT
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
5
5
 
6
6
  [tool.poetry]
7
7
  name = "swarms"
8
- version = "7.7.5"
8
+ version = "7.7.7"
9
9
  description = "Swarms - TGSC"
10
10
  license = "MIT"
11
11
  authors = ["Kye Gomez <kye@apac.ai>"]
@@ -87,7 +87,7 @@ swarms = "swarms.cli.main:main"
87
87
 
88
88
  [tool.poetry.group.lint.dependencies]
89
89
  black = ">=23.1,<26.0"
90
- ruff = ">=0.5.1,<0.11.8"
90
+ ruff = ">=0.5.1,<0.11.9"
91
91
  types-toml = "^0.10.8.1"
92
92
  types-pytz = ">=2023.3,<2026.0"
93
93
  types-chardet = "^5.0.4.6"
@@ -25,7 +25,6 @@ from swarms.structs.stopping_conditions import (
25
25
  )
26
26
 
27
27
  __all__ = [
28
- # "ToolAgent",
29
28
  "check_done",
30
29
  "check_finished",
31
30
  "check_complete",
@@ -46,6 +46,7 @@ class Message:
46
46
 
47
47
  class DateTimeEncoder(json.JSONEncoder):
48
48
  """Custom JSON encoder for handling datetime objects."""
49
+
49
50
  def default(self, obj):
50
51
  if isinstance(obj, datetime.datetime):
51
52
  return obj.isoformat()
@@ -540,7 +541,10 @@ class DuckDBConversation:
540
541
  except json.JSONDecodeError:
541
542
  pass
542
543
 
543
- message = {"role": row[0], "content": content} # role column
544
+ message = {
545
+ "role": row[0],
546
+ "content": content,
547
+ } # role column
544
548
 
545
549
  if row[2]: # timestamp column
546
550
  message["timestamp"] = row[2]
@@ -562,7 +566,9 @@ class DuckDBConversation:
562
566
  Returns:
563
567
  str: JSON string representation of the conversation
564
568
  """
565
- return json.dumps(self.to_dict(), indent=2, cls=DateTimeEncoder)
569
+ return json.dumps(
570
+ self.to_dict(), indent=2, cls=DateTimeEncoder
571
+ )
566
572
 
567
573
  def to_yaml(self) -> str:
568
574
  """
@@ -585,7 +591,9 @@ class DuckDBConversation:
585
591
  """
586
592
  try:
587
593
  with open(filename, "w") as f:
588
- json.dump(self.to_dict(), f, indent=2, cls=DateTimeEncoder)
594
+ json.dump(
595
+ self.to_dict(), f, indent=2, cls=DateTimeEncoder
596
+ )
589
597
  return True
590
598
  except Exception as e:
591
599
  if self.enable_logging:
@@ -614,12 +622,13 @@ class DuckDBConversation:
614
622
  # Add all messages
615
623
  for message in messages:
616
624
  # Convert timestamp string back to datetime if it exists
617
- timestamp = None
618
625
  if "timestamp" in message:
619
626
  try:
620
- timestamp = datetime.datetime.fromisoformat(message["timestamp"])
627
+ datetime.datetime.fromisoformat(
628
+ message["timestamp"]
629
+ )
621
630
  except (ValueError, TypeError):
622
- timestamp = message["timestamp"]
631
+ message["timestamp"]
623
632
 
624
633
  self.add(
625
634
  role=message["role"],
@@ -0,0 +1,48 @@
1
+ def generate_reasoning_prompt(max_loops: int) -> str:
2
+ # You are a deliberate, step-by-step reasoning agent designed to solve complex problems
3
+ # through iterative reasoning loops.
4
+
5
+ return f"""
6
+ Your task is to perform **exactly one loop per generation**,
7
+ until either the problem is solved or you have completed {max_loops} loops.
8
+
9
+ ## Instructions:
10
+
11
+ - In this generation, perform loop number {{current_loop}} out of {max_loops}.
12
+ - **Do not perform more than one loop in a single generation.**
13
+ - Use the **maximum token budget** available to explore, reason, and reflect.
14
+ - Output must **end** with:
15
+ - `### End of Loop {{current_loop}}`
16
+ - **Do not proceed to loop {{current_loop + 1}}** unless explicitly prompted again.
17
+
18
+ ## Loop Structure (per generation):
19
+
20
+ 1. **Summarize the Current State**
21
+ - Recap known information, intermediate thoughts, or context.
22
+
23
+ 2. **Generate Hypotheses**
24
+ - Explore possible next steps, questions, or subproblems.
25
+
26
+ 3. **Evaluate and Choose**
27
+ - Narrow down based on logic or likelihood of success.
28
+
29
+ 4. **Act and Update Memory**
30
+ - Take the chosen step, modify internal reasoning or beliefs.
31
+
32
+ 5. **Reflect**
33
+ - Consider whether this step brings you closer to solving the problem.
34
+ - Suggest whether to continue, backtrack, or finalize.
35
+
36
+ ## Stopping Criteria:
37
+ - You will stop reasoning when:
38
+ - The final answer is found and clearly stated.
39
+ - {max_loops} loops have been completed.
40
+ - You conclude that continued reasoning won't help.
41
+
42
+ In the final loop (loop {max_loops}), output your final solution as:
43
+
44
+ **Final Answer:**
45
+
46
+ Be methodical, reflective, and token-efficient. Use all available room to think in detail.
47
+ Do not rush to conclusions. Each loop is isolated and should be treated as its own generation.
48
+ """
@@ -0,0 +1,41 @@
1
+ REACT_SYS_PROMPT = """You are a thoughtful and methodical AI agent. You solve problems through careful reasoning and by using external tools when needed. You use a "Thought → Action → Observation" loop, repeating as many times as needed to build your understanding and solve the problem. Your goal is not just to answer correctly, but to demonstrate clear reasoning and adaptability.
2
+
3
+ Follow this structure:
4
+
5
+ ---
6
+
7
+ Question: [The user’s input]
8
+
9
+ Thought 1: Understand the question. What is being asked? Break it down into sub-parts. What knowledge or information might be required?
10
+
11
+ Thought 2: Form a plan. Decide what steps to take. Which facts should be recalled? Which need to be looked up? Which tools should be used?
12
+
13
+ Action 1: [Use a tool, such as Search[query], Lookup[entity], Calculator[expression], or even Plan[...] if you need to set subgoals]
14
+ Observation 1: [The result from the tool]
15
+
16
+ Thought 3: Reflect on the observation. What did you learn? What do you now know or still not know? Update your plan if needed.
17
+
18
+ Action 2: [Next tool or operation]
19
+ Observation 2: [...]
20
+
21
+ ...
22
+
23
+ [Repeat Thought → Action → Observation as needed]
24
+
25
+ Thought N: You now have all the necessary information. Synthesize what you know. Reconstruct the answer clearly, and justify it.
26
+
27
+ Action N: Finish[final_answer]
28
+
29
+ ---
30
+
31
+ Guidelines for Reasoning:
32
+ - Always **start by interpreting the problem carefully.**
33
+ - If the question is complex, **break it into parts** and tackle each.
34
+ - **Think before you act.** Plan actions deliberately, not reflexively.
35
+ - Use **search engines** or **lookup tools** for facts, definitions, or current events.
36
+ - Use a **calculator** for numerical operations.
37
+ - Use **Reflection** steps if your observations are unclear, surprising, or contradictory.
38
+ - Don't rush to finish — **reasoning is more important than speed.**
39
+ - When concluding, make sure your **answer is fully supported** by earlier steps.
40
+
41
+ """
@@ -39,12 +39,19 @@ from swarms.schemas.base_schemas import (
39
39
  )
40
40
  from swarms.structs.agent_roles import agent_roles
41
41
  from swarms.structs.conversation import Conversation
42
+ from swarms.structs.output_types import OutputType
42
43
  from swarms.structs.safe_loading import (
43
44
  SafeLoaderUtils,
44
45
  SafeStateManager,
45
46
  )
46
47
  from swarms.telemetry.main import log_agent_data
47
48
  from swarms.tools.base_tool import BaseTool
49
+ from swarms.tools.mcp_client import (
50
+ execute_mcp_tool,
51
+ find_and_execute_tool,
52
+ list_all,
53
+ list_tools_for_multiple_urls,
54
+ )
48
55
  from swarms.tools.mcp_integration import MCPServerSseParams
49
56
  from swarms.tools.tool_parse_exec import parse_and_execute_json
50
57
  from swarms.utils.any_to_str import any_to_str
@@ -57,14 +64,9 @@ from swarms.utils.history_output_formatter import (
57
64
  from swarms.utils.litellm_tokenizer import count_tokens
58
65
  from swarms.utils.litellm_wrapper import LiteLLM
59
66
  from swarms.utils.pdf_to_text import pdf_to_text
60
- from swarms.structs.output_types import OutputType
61
67
  from swarms.utils.str_to_dict import str_to_dict
62
- from swarms.tools.mcp_client import (
63
- execute_mcp_tool,
64
- list_tools_for_multiple_urls,
65
- list_all,
66
- find_and_execute_tool,
67
- )
68
+ from swarms.prompts.react_base_prompt import REACT_SYS_PROMPT
69
+ from swarms.prompts.max_loop_prompt import generate_reasoning_prompt
68
70
 
69
71
 
70
72
  # Utils
@@ -302,7 +304,7 @@ class Agent:
302
304
  saved_state_path: Optional[str] = None,
303
305
  autosave: Optional[bool] = False,
304
306
  context_length: Optional[int] = 8192,
305
- user_name: Optional[str] = "Human:",
307
+ user_name: Optional[str] = "Human",
306
308
  self_healing_enabled: Optional[bool] = False,
307
309
  code_interpreter: Optional[bool] = False,
308
310
  multi_modal: Optional[bool] = None,
@@ -396,6 +398,7 @@ class Agent:
396
398
  mcp_servers: MCPServerSseParams = None,
397
399
  mcp_url: str = None,
398
400
  mcp_urls: List[str] = None,
401
+ react_on: bool = False,
399
402
  *args,
400
403
  **kwargs,
401
404
  ):
@@ -518,12 +521,13 @@ class Agent:
518
521
  self.mcp_servers = mcp_servers
519
522
  self.mcp_url = mcp_url
520
523
  self.mcp_urls = mcp_urls
524
+ self.react_on = react_on
521
525
 
522
526
  self._cached_llm = (
523
527
  None # Add this line to cache the LLM instance
524
528
  )
525
529
 
526
- self.short_memory = self.short_memory_init()
530
+ # self.short_memory = self.short_memory_init()
527
531
 
528
532
  # Initialize the feedback
529
533
  self.feedback = []
@@ -555,6 +559,16 @@ class Agent:
555
559
  if self.mcp_url or self.mcp_servers is not None:
556
560
  self.add_mcp_tools_to_memory()
557
561
 
562
+ if self.react_on is True:
563
+ self.system_prompt += REACT_SYS_PROMPT
564
+
565
+ if self.max_loops > 1:
566
+ self.system_prompt += generate_reasoning_prompt(
567
+ self.max_loops
568
+ )
569
+
570
+ self.short_memory = self.short_memory_init()
571
+
558
572
  def short_memory_init(self):
559
573
  if (
560
574
  self.agent_name is not None
@@ -575,33 +589,6 @@ class Agent:
575
589
 
576
590
  return self.short_memory
577
591
 
578
- def init_handling(self):
579
- # Define tasks as pairs of (function, condition)
580
- # Each task will only run if its condition is True
581
- self.setup_config()
582
-
583
- if exists(self.docs_folder):
584
- self.get_docs_from_doc_folders()
585
-
586
- if exists(self.tools):
587
- self.handle_tool_init()
588
-
589
- if exists(self.tool_schema) or exists(self.list_base_models):
590
- self.handle_tool_schema_ops()
591
-
592
- if exists(self.sop) or exists(self.sop_list):
593
- self.handle_sop_ops()
594
-
595
- # Run sequential operations after all concurrent tasks are done
596
- # self.agent_output = self.agent_output_model()
597
- log_agent_data(self.to_dict())
598
-
599
- if self.llm is None:
600
- self.llm = self.llm_handling()
601
-
602
- if self.mcp_url or self.mcp_servers is not None:
603
- self.add_mcp_tools_to_memory()
604
-
605
592
  def agent_output_model(self):
606
593
  # Many steps
607
594
  id = agent_id()
@@ -1021,24 +1008,13 @@ class Agent:
1021
1008
  agent(task="What is the capital of France?", img="path/to/image.jpg", is_last=True)
1022
1009
  """
1023
1010
  try:
1024
- # 1. Batch process initial setup
1025
- setup_tasks = [
1026
- lambda: self.check_if_no_prompt_then_autogenerate(
1027
- task
1028
- ),
1029
- lambda: self.short_memory.add(
1030
- role=self.user_name, content=task
1031
- ),
1032
- lambda: (
1033
- self.plan(task) if self.plan_enabled else None
1034
- ),
1035
- ]
1036
1011
 
1037
- # Execute setup tasks concurrently
1038
- with ThreadPoolExecutor(
1039
- max_workers=len(setup_tasks)
1040
- ) as executor:
1041
- executor.map(lambda f: f(), setup_tasks)
1012
+ self.check_if_no_prompt_then_autogenerate(task)
1013
+
1014
+ self.short_memory.add(role=self.user_name, content=task)
1015
+
1016
+ if self.plan_enabled:
1017
+ self.plan(task)
1042
1018
 
1043
1019
  # Set the loop count
1044
1020
  loop_count = 0
@@ -1068,10 +1044,18 @@ class Agent:
1068
1044
  ):
1069
1045
  loop_count += 1
1070
1046
 
1071
- # self.short_memory.add(
1072
- # role=f"{self.agent_name}",
1073
- # content=f"Internal Reasoning Loop: {loop_count} of {self.max_loops}",
1074
- # )
1047
+ if self.max_loops > 1:
1048
+ self.short_memory.add(
1049
+ role=self.agent_name,
1050
+ content=f"Current Internal Reasoning Loop: {loop_count}/{self.max_loops}",
1051
+ )
1052
+
1053
+ # If it is the final loop, then add the final loop message
1054
+ if loop_count == self.max_loops:
1055
+ self.short_memory.add(
1056
+ role=self.agent_name,
1057
+ content=f"🎉 Final Internal Reasoning Loop: {loop_count}/{self.max_loops} Prepare your comprehensive response.",
1058
+ )
1075
1059
 
1076
1060
  # Dynamic temperature
1077
1061
  if self.dynamic_temperature_enabled is True:
@@ -1111,31 +1095,15 @@ class Agent:
1111
1095
  # Convert to a str if the response is not a str
1112
1096
  response = self.parse_llm_output(response)
1113
1097
 
1114
- # self.short_memory.add(
1115
- # role=self.agent_name, content=response
1116
- # )
1117
-
1118
- # # Print
1119
- # self.pretty_print(response, loop_count)
1120
-
1121
- # # Output Cleaner
1122
- # self.output_cleaner_op(response)
1098
+ self.short_memory.add(
1099
+ role=self.agent_name, content=response
1100
+ )
1123
1101
 
1124
- # 9. Batch memory updates and prints
1125
- update_tasks = [
1126
- lambda: self.short_memory.add(
1127
- role=self.agent_name, content=response
1128
- ),
1129
- lambda: self.pretty_print(
1130
- response, loop_count
1131
- ),
1132
- lambda: self.output_cleaner_op(response),
1133
- ]
1102
+ # Print
1103
+ self.pretty_print(response, loop_count)
1134
1104
 
1135
- with ThreadPoolExecutor(
1136
- max_workers=len(update_tasks)
1137
- ) as executor:
1138
- executor.map(lambda f: f(), update_tasks)
1105
+ # Output Cleaner
1106
+ self.output_cleaner_op(response)
1139
1107
 
1140
1108
  ####### MCP TOOL HANDLING #######
1141
1109
  if (
@@ -1156,26 +1124,28 @@ class Agent:
1156
1124
  role="Tool Executor", content=out
1157
1125
  )
1158
1126
 
1159
- agent_print(
1160
- f"{self.agent_name} - Tool Executor",
1161
- out,
1162
- loop_count,
1163
- self.streaming_on,
1164
- )
1127
+ if self.no_print is False:
1128
+ agent_print(
1129
+ f"{self.agent_name} - Tool Executor",
1130
+ out,
1131
+ loop_count,
1132
+ self.streaming_on,
1133
+ )
1165
1134
 
1166
- out = self.llm.run(out)
1167
-
1168
- agent_print(
1169
- f"{self.agent_name} - Agent Analysis",
1170
- out,
1171
- loop_count,
1172
- self.streaming_on,
1173
- )
1135
+ out = self.call_llm(task=out)
1174
1136
 
1175
1137
  self.short_memory.add(
1176
1138
  role=self.agent_name, content=out
1177
1139
  )
1178
1140
 
1141
+ if self.no_print is False:
1142
+ agent_print(
1143
+ f"{self.agent_name} - Agent Analysis",
1144
+ out,
1145
+ loop_count,
1146
+ self.streaming_on,
1147
+ )
1148
+
1179
1149
  self.sentiment_and_evaluator(response)
1180
1150
 
1181
1151
  success = True # Mark as successful to exit the retry loop
@@ -1233,7 +1203,7 @@ class Agent:
1233
1203
  break
1234
1204
 
1235
1205
  self.short_memory.add(
1236
- role="User", content=user_input
1206
+ role=self.user_name, content=user_input
1237
1207
  )
1238
1208
 
1239
1209
  if self.loop_interval:
@@ -1247,21 +1217,10 @@ class Agent:
1247
1217
 
1248
1218
  self.save()
1249
1219
 
1250
- # log_agent_data(self.to_dict())
1251
-
1252
- # if self.autosave is True:
1253
- # self.save()
1254
-
1255
- # 14. Batch final operations
1256
- final_tasks = [
1257
- lambda: log_agent_data(self.to_dict()),
1258
- lambda: self.save() if self.autosave else None,
1259
- ]
1220
+ log_agent_data(self.to_dict())
1260
1221
 
1261
- with ThreadPoolExecutor(
1262
- max_workers=len(final_tasks)
1263
- ) as executor:
1264
- executor.map(lambda f: f(), final_tasks)
1222
+ if self.autosave:
1223
+ self.save()
1265
1224
 
1266
1225
  return history_output_formatter(
1267
1226
  self.short_memory, type=self.output_type
@@ -2738,6 +2697,8 @@ class Agent:
2738
2697
  f"{self.agent_name}: {response}",
2739
2698
  title=f"Agent Name: {self.agent_name} [Max Loops: {loop_count}]",
2740
2699
  )
2700
+ elif self.no_print is True:
2701
+ pass
2741
2702
  else:
2742
2703
  # logger.info(f"Response: {response}")
2743
2704
  formatter.print_panel(