|
67 | 67 | MAX_SUBTASK_ITERATIONS, |
68 | 68 | MAX_SUBTASK_LOOPS, |
69 | 69 | assign_task_tool, |
| 70 | + check_sub_agent_status_tool, |
| 71 | + cancel_sub_agent_tasks_tool, |
70 | 72 | create_file_tool, |
71 | 73 | create_sub_agent_tool, |
72 | 74 | delete_file_tool, |
|
82 | 84 | update_file_tool, |
83 | 85 | ) |
84 | 86 | from swarms.structs.conversation import Conversation |
| 87 | +from swarms.structs.dynamic_skills_loader import DynamicSkillsLoader |
85 | 88 | from swarms.structs.ma_utils import set_random_models_for_agents |
86 | 89 | from swarms.structs.safe_loading import ( |
87 | 90 | SafeLoaderUtils, |
|
126 | 129 | add_prompt_to_marketplace, |
127 | 130 | ) |
128 | 131 | from swarms.utils.workspace_utils import get_workspace_dir |
129 | | -from swarms.structs.dynamic_skills_loader import DynamicSkillsLoader |
130 | 132 |
|
131 | 133 |
|
132 | 134 | def stop_when_repeats(response: str) -> bool: |
@@ -426,7 +428,7 @@ def __init__( |
426 | 428 | random_models_on: bool = False, |
427 | 429 | mcp_config: Optional[MCPConnection] = None, |
428 | 430 | mcp_configs: Optional[MultipleMCPConnections] = None, |
429 | | - top_p: Optional[float] = 0.90, |
| 431 | + top_p: Optional[float] = None, |
430 | 432 | llm_base_url: Optional[str] = None, |
431 | 433 | llm_api_key: Optional[str] = None, |
432 | 434 | tool_call_summary: bool = True, |
@@ -2324,6 +2326,12 @@ def _run_autonomous_loop( |
2324 | 2326 | "assign_task": lambda **kwargs: assign_task_tool( |
2325 | 2327 | self, **kwargs |
2326 | 2328 | ), |
| 2329 | + "check_sub_agent_status": lambda **kwargs: check_sub_agent_status_tool( |
| 2330 | + self, **kwargs |
| 2331 | + ), |
| 2332 | + "cancel_sub_agent_tasks": lambda **kwargs: cancel_sub_agent_tasks_tool( |
| 2333 | + self, **kwargs |
| 2334 | + ), |
2327 | 2335 | } |
2328 | 2336 |
|
2329 | 2337 | # Filter tool handlers if selected_tools is not "all" |
@@ -3119,83 +3127,6 @@ async def arun( |
3119 | 3127 | error |
3120 | 3128 | ) # Ensure this is also async if needed |
3121 | 3129 |
|
3122 | | - # ── Async Subagent Methods ────────────────────────────── |
3123 | | - |
3124 | | - def _get_registry(self): |
3125 | | - """Lazy-init and return the SubagentRegistry.""" |
3126 | | - if self._subagent_registry is None: |
3127 | | - from swarms.structs.async_subagent import ( |
3128 | | - SubagentRegistry, |
3129 | | - ) |
3130 | | - |
3131 | | - self._subagent_registry = SubagentRegistry( |
3132 | | - max_depth=self.max_subagent_depth |
3133 | | - ) |
3134 | | - return self._subagent_registry |
3135 | | - |
3136 | | - def run_async(self, task: str): |
3137 | | - """ |
3138 | | - Run this agent's task in the background, returning a Future. |
3139 | | - """ |
3140 | | - registry = self._get_registry() |
3141 | | - return registry._executor.submit(self.run, task) |
3142 | | - |
3143 | | - def spawn_async( |
3144 | | - self, |
3145 | | - agent, |
3146 | | - task: str, |
3147 | | - max_retries: int = 0, |
3148 | | - retry_on=None, |
3149 | | - fail_fast: bool = True, |
3150 | | - ) -> str: |
3151 | | - """ |
3152 | | - Spawn a subagent to run a task in the background. |
3153 | | -
|
3154 | | - Returns task_id for tracking via get_subagent_results() / gather_results(). |
3155 | | - """ |
3156 | | - registry = self._get_registry() |
3157 | | - return registry.spawn( |
3158 | | - agent=agent, |
3159 | | - task=task, |
3160 | | - parent_id=self.id, |
3161 | | - depth=0, |
3162 | | - max_retries=max_retries, |
3163 | | - retry_on=retry_on, |
3164 | | - fail_fast=fail_fast, |
3165 | | - ) |
3166 | | - |
3167 | | - def run_in_background(self, task: str) -> str: |
3168 | | - """ |
3169 | | - Convenience: spawn self as a background task, return task_id. |
3170 | | - """ |
3171 | | - registry = self._get_registry() |
3172 | | - return registry.spawn( |
3173 | | - agent=self, |
3174 | | - task=task, |
3175 | | - parent_id=None, |
3176 | | - depth=0, |
3177 | | - ) |
3178 | | - |
3179 | | - def gather_results( |
3180 | | - self, |
3181 | | - strategy: str = "wait_all", |
3182 | | - timeout: float = None, |
3183 | | - ): |
3184 | | - """Wait for spawned subagents and return their results.""" |
3185 | | - return self._get_registry().gather( |
3186 | | - strategy=strategy, timeout=timeout |
3187 | | - ) |
3188 | | - |
3189 | | - def get_subagent_results(self): |
3190 | | - """Collect results from all completed subagent tasks.""" |
3191 | | - return self._get_registry().get_results() |
3192 | | - |
3193 | | - def cancel_subagent(self, task_id: str) -> bool: |
3194 | | - """Cancel a spawned subagent task.""" |
3195 | | - return self._get_registry().cancel(task_id) |
3196 | | - |
3197 | | - # ── End Async Subagent Methods ────────────────────────── |
3198 | | - |
3199 | 3130 | def __call__( |
3200 | 3131 | self, |
3201 | 3132 | task: Optional[str] = None, |
|
0 commit comments