๐ซ CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
feat: Workforce human in the loop (#2518)
Tao Sundfec46d7e031
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.ymlindex 226e16061..ed26c5dac 100644--- a/.github/ISSUE_TEMPLATE/bug_report.yml+++ b/.github/ISSUE_TEMPLATE/bug_report.yml@@ -26,7 +26,7 @@ body:attributes:label: What version of camel are you using?description: Run command `python3 -c 'print(__import__("camel").__version__)'` in your shell and paste the output here.- placeholder: E.g., 0.2.66+ placeholder: E.g., 0.2.67validations:required: truediff --git a/camel/__init__.py b/camel/__init__.pyindex 2421cfcc3..895aa1b93 100644--- a/camel/__init__.py+++ b/camel/__init__.py@@ -14,7 +14,7 @@from camel.logger import disable_logging, enable_logging, set_log_level-__version__ = '0.2.66'+__version__ = '0.2.67'__all__ = ['__version__',diff --git a/camel/societies/workforce/workforce.py b/camel/societies/workforce/workforce.pyindex 847c04aa9..80bd4c39c 100644--- a/camel/societies/workforce/workforce.py+++ b/camel/societies/workforce/workforce.py@@ -15,9 +15,11 @@ from __future__ import annotationsimport asyncioimport json+import timeimport uuidfrom collections import deque-from typing import Any, Deque, Dict, List, Optional, Set+from enum import Enum+from typing import Any, Coroutine, Deque, Dict, List, Optionalfrom colorama import Fore@@ -55,6 +57,42 @@ from .workforce_logger import WorkforceLoggerlogger = get_logger(__name__)+class WorkforceState(Enum):+ r"""Workforce execution state for human intervention support."""++ IDLE = "idle"+ RUNNING = "running"+ PAUSED = "paused"+ STOPPED = "stopped"+++class WorkforceSnapshot:+ r"""Snapshot of workforce state for resuming execution."""++ def __init__(+ self,+ main_task: Optional[Task] = None,+ pending_tasks: Optional[Deque[Task]] = None,+ completed_tasks: Optional[List[Task]] = None,+ task_dependencies: Optional[Dict[str, List[str]]] = None,+ assignees: Optional[Dict[str, str]] = None,+ current_task_index: int = 0,+ description: str = "",+ ):+ self.main_task = main_task+ self.pending_tasks = pending_tasks.copy() if pending_tasks else deque()+ self.completed_tasks = (+ completed_tasks.copy() if completed_tasks else []+ )+ self.task_dependencies = (+ task_dependencies.copy() if task_dependencies else {}+ )+ self.assignees = assignees.copy() if assignees else {}+ self.current_task_index = current_task_index+ self.description = description+ self.timestamp = time.time()++class Workforce(BaseNode):r"""A system where multiple worker nodes (agents) cooperate togetherto solve tasks. It can assign tasks to worker nodes and also take@@ -123,7 +161,7 @@ class Workforce(BaseNode):>>> # Process a task>>> async def main():... task = Task(content="Research AI trends", id="1")- ... result = await workforce.process_task(task)+ ... result = workforce.process_task(task)... return result>>> asyncio.run(main())"""@@ -145,9 +183,26 @@ class Workforce(BaseNode):self.graceful_shutdown_timeout = graceful_shutdown_timeoutself.share_memory = share_memoryself.metrics_logger = WorkforceLogger(workforce_id=self.node_id)+ self._task: Optional[Task] = None+ self._pending_tasks: Deque[Task] = deque()+ self._task_dependencies: Dict[str, List[str]] = {}+ self._assignees: Dict[str, str] = {}+ self._in_flight_tasks: int = 0# Dictionary to track task start timesself._task_start_times: Dict[str, float] = {}-+ # Human intervention support+ self._state = WorkforceState.IDLE+ self._pause_event = asyncio.Event()+ self._pause_event.set() # Initially not paused+ self._stop_requested = False+ self._snapshots: List[WorkforceSnapshot] = []+ self._completed_tasks: List[Task] = []+ self._loop: Optional[asyncio.AbstractEventLoop] = None+ self._main_task_future: Optional[asyncio.Future] = None+ # Snapshot throttle support+ self._last_snapshot_time: float = 0.0+ # Minimum seconds between automatic snapshots+ self.snapshot_interval: float = 30.0if self.metrics_logger:for child in self._children:worker_type = type(child).__name__@@ -224,16 +279,11 @@ class Workforce(BaseNode):_kwargs["tools"] = [*_kwargs.get("tools", []), *extra_tools]self.task_agent = ChatAgent(task_sys_msg, **_kwargs)- # If there is one, will set by the workforce class wrapping this- self._task: Optional[Task] = None- self._pending_tasks: Deque[Task] = deque()- self._completed_tasks: Set[str] = set()- self._task_dependencies: Dict[str, List[str]] = {}- self._assignees: Dict[str, str] = {}- self._in_flight_tasks: int = 0-def __repr__(self):- return f"Workforce {self.node_id} ({self.description})"+ return (+ f"Workforce {self.node_id} ({self.description}) - "+ f"State: {self._state.value}"+ )def _collect_shared_memory(self) -> Dict[str, List]:r"""Collect memory from all SingleAgentWorker instances for sharing.@@ -308,7 +358,7 @@ class Workforce(BaseNode):from camel.memories.records import MemoryRecord# Create consolidated memory objects from records- memory_records = []+ memory_records: List[MemoryRecord] = []for record_dict in all_records:try:memory_record = MemoryRecord.from_dict(record_dict)@@ -383,18 +433,313 @@ class Workforce(BaseNode):return subtasks+ # Human intervention methods+ async def _async_pause(self) -> None:+ r"""Async implementation of pause to run on the event loop."""+ if self._state == WorkforceState.RUNNING:+ self._state = WorkforceState.PAUSED+ self._pause_event.clear()+ logger.info(f"Workforce {self.node_id} paused.")++ def pause(self) -> None:+ r"""Pause the workforce execution.+ If the internal event-loop is already running we schedule the+ asynchronous pause coroutine onto it. When the loop has not yet+ been created (e.g. the caller presses the hot-key immediately after+ workforce start-up) we fall back to a synchronous state change so+ that no tasks will be scheduled until the loop is ready.+ """++ if self._loop and not self._loop.is_closed():+ self._submit_coro_to_loop(self._async_pause())+ else:+ # Loop not yet created, just mark state so when loop starts it+ # will proceed.+ if self._state == WorkforceState.RUNNING:+ self._state = WorkforceState.PAUSED+ self._pause_event.clear()+ logger.info(+ f"Workforce {self.node_id} paused "+ f"(event-loop not yet started)."+ )++ async def _async_resume(self) -> None:+ r"""Async implementation of resume to run on the event loop."""+ if self._state == WorkforceState.PAUSED:+ self._state = WorkforceState.RUNNING+ self._pause_event.set()+ logger.info(f"Workforce {self.node_id} resumed.")++ # Re-post ready tasks (if any)+ if self._pending_tasks:+ await self._post_ready_tasks()++ def resume(self) -> None:+ r"""Resume execution after a manual pause."""++ if self._loop and not self._loop.is_closed():+ self._submit_coro_to_loop(self._async_resume())+ else:+ # Loop not running yet, just mark state so when loop starts it+ # will proceed.+ if self._state == WorkforceState.PAUSED:+ self._state = WorkforceState.RUNNING+ self._pause_event.set()+ logger.info(+ f"Workforce {self.node_id} resumed "+ f"(event-loop not yet started)."+ )++ async def _async_stop_gracefully(self) -> None:+ r"""Async implementation of stop_gracefully to run on the event+ loop.+ """+ self._stop_requested = True+ if self._pause_event.is_set() is False:+ self._pause_event.set() # Resume if paused to process stop+ logger.info(f"Workforce {self.node_id} stop requested.")++ def stop_gracefully(self) -> None:+ r"""Request workforce to finish current in-flight work then halt.++ Works both when the internal event-loop is alive and when it has not+ yet been started. In the latter case we simply mark the stop flag so+ that the loop (when it eventually starts) will exit immediately after+ initialisation.+ """++ if self._loop and not self._loop.is_closed():+ self._submit_coro_to_loop(self._async_stop_gracefully())+ else:+ # Loop not yet created, set the flag synchronously so later+ # startup will respect it.+ self._stop_requested = True+ # Ensure any pending pause is released so that when the loop does+ # start it can see the stop request and exit.+ self._pause_event.set()+ logger.info(+ f"Workforce {self.node_id} stop requested "+ f"(event-loop not yet started)."+ )++ def save_snapshot(self, description: str = "") -> None:+ r"""Save current state as a snapshot."""+ snapshot = WorkforceSnapshot(+ main_task=self._task,+ pending_tasks=self._pending_tasks,+ completed_tasks=self._completed_tasks,+ task_dependencies=self._task_dependencies,+ assignees=self._assignees,+ current_task_index=len(self._completed_tasks),+ description=description or f"Snapshot at {time.time()}",+ )+ self._snapshots.append(snapshot)+ logger.info(f"Snapshot saved: {description}")++ def list_snapshots(self) -> List[str]:+ r"""List all available snapshots."""+ snapshots_info = []+ for i, snapshot in enumerate(self._snapshots):+ desc_part = (+ f" - {snapshot.description}" if snapshot.description else ""+ )+ info = (+ f"Snapshot {i}: {len(snapshot.completed_tasks)} completed, "+ f"{len(snapshot.pending_tasks)} pending{desc_part}"+ )+ snapshots_info.append(info)+ return snapshots_info++ def get_pending_tasks(self) -> List[Task]:+ r"""Get current pending tasks for human review."""+ return list(self._pending_tasks)++ def get_completed_tasks(self) -> List[Task]:+ r"""Get completed tasks."""+ return self._completed_tasks.copy()++ def modify_task_content(self, task_id: str, new_content: str) -> bool:+ r"""Modify the content of a pending task."""+ # Validate the new content first+ if not validate_task_content(new_content, task_id):+ logger.warning(+ f"Task {task_id} content modification rejected: "+ f"Invalid content. Content preview: '{new_content[:50]}...'"+ )+ return False++ for task in self._pending_tasks:+ if task.id == task_id:+ task.content = new_content+ logger.info(f"Task {task_id} content modified.")+ return True+ logger.warning(f"Task {task_id} not found in pending tasks.")+ return False++ def add_task(+ self,+ content: str,+ task_id: Optional[str] = None,+ additional_info: Optional[Dict[str, Any]] = None,+ insert_position: int = -1,+ ) -> Task:+ r"""Add a new task to the pending queue."""+ new_task = Task(+ content=content,+ id=task_id or f"human_added_{len(self._pending_tasks)}",+ additional_info=additional_info,+ )+ if insert_position == -1:+ self._pending_tasks.append(new_task)+ else:+ # Convert deque to list, insert, then back to deque+ tasks_list = list(self._pending_tasks)+ tasks_list.insert(insert_position, new_task)+ self._pending_tasks = deque(tasks_list)++ logger.info(f"New task added: {new_task.id}")+ return new_task++ def remove_task(self, task_id: str) -> bool:+ r"""Remove a task from the pending queue."""+ # Convert to list to find and remove+ tasks_list = list(self._pending_tasks)+ for i, task in enumerate(tasks_list):+ if task.id == task_id:+ tasks_list.pop(i)+ self._pending_tasks = deque(tasks_list)+ logger.info(f"Task {task_id} removed.")+ return True+ logger.warning(f"Task {task_id} not found in pending tasks.")+ return False++ def reorder_tasks(self, task_ids: List[str]) -> bool:+ r"""Reorder pending tasks according to the provided task IDs list."""+ # Create a mapping of task_id to task+ tasks_dict = {task.id: task for task in self._pending_tasks}++ # Check if all provided IDs exist+ if not all(task_id in tasks_dict for task_id in task_ids):+ logger.warning("Some task IDs not found in pending tasks.")+ return False++ # Check if we have the same number of tasks+ if len(task_ids) != len(self._pending_tasks):+ logger.warning(+ "Number of task IDs doesn't match pending tasks count."+ )+ return False++ # Reorder tasks+ reordered_tasks = deque([tasks_dict[task_id] for task_id in task_ids])+ self._pending_tasks = reordered_tasks++ logger.info("Tasks reordered successfully.")+ return True++ def resume_from_task(self, task_id: str) -> bool:+ r"""Resume execution from a specific task."""+ if self._state != WorkforceState.PAUSED:+ logger.warning(+ "Workforce must be paused to resume from specific task."+ )+ return False++ # Find the task in pending tasks+ tasks_list = list(self._pending_tasks)+ target_index = -1++ for i, task in enumerate(tasks_list):+ if task.id == task_id:+ target_index = i+ break++ if target_index == -1:+ logger.warning(f"Task {task_id} not found in pending tasks.")+ return False++ # Move completed tasks that come after the target task back to pending+ tasks_to_move_back = tasks_list[:target_index]+ remaining_tasks = tasks_list[target_index:]++ # Update pending tasks to start from the target task+ self._pending_tasks = deque(remaining_tasks)++ # Move previously "completed" tasks that are after target back to+ # pending and reset their state+ if tasks_to_move_back:+ # Reset state for tasks being moved back to pending+ for task in tasks_to_move_back:+ # Handle all possible task states+ if task.state in [TaskState.DONE, TaskState.FAILED]:+ task.state = TaskState.OPEN+ # Clear result to avoid confusion+ task.result = None+ # Reset failure count to give task a fresh start+ task.failure_count = 0++ logger.info(+ f"Moving {len(tasks_to_move_back)} tasks back to pending "+ f"state."+ )++ logger.info(f"Ready to resume from task: {task_id}")+ return True++ def restore_from_snapshot(self, snapshot_index: int) -> bool:+ r"""Restore workforce state from a snapshot."""+ if not (0 <= snapshot_index < len(self._snapshots)):+ logger.warning(f"Invalid snapshot index: {snapshot_index}")+ return False++ if self._state == WorkforceState.RUNNING:+ logger.warning(+ "Cannot restore snapshot while workforce is running. "+ "Pause first."+ )+ return False++ snapshot = self._snapshots[snapshot_index]+ self._task = snapshot.main_task+ self._pending_tasks = snapshot.pending_tasks.copy()+ self._completed_tasks = snapshot.completed_tasks.copy()+ self._task_dependencies = snapshot.task_dependencies.copy()+ self._assignees = snapshot.assignees.copy()++ logger.info(f"Workforce state restored from snapshot {snapshot_index}")+ return True++ def get_workforce_status(self) -> Dict:+ r"""Get current workforce status for human review."""+ return {+ "state": self._state.value,+ "pending_tasks_count": len(self._pending_tasks),+ "completed_tasks_count": len(self._completed_tasks),+ "snapshots_count": len(self._snapshots),+ "children_count": len(self._children),+ "main_task_id": self._task.id if self._task else None,+ }+@check_if_running(False)- async def process_task(self, task: Task) -> Task:- r"""The main entry point for the workforce to process a task. It will- start the workforce and all the child nodes under it, process the- task provided and return the updated task.+ async def process_task_async(+ self, task: Task, interactive: bool = False+ ) -> Task:+ r"""Main entry point to process a task asynchronously.Args:task (Task): The task to be processed.+ interactive (bool, optional): If True, enables human-intervention+ workflow (pause/resume/snapshot). Defaults to False, which+ runs the task in a blocking one-shot manner.Returns:Task: The updated task."""+ # Delegate to intervention pipeline when requested to keep+ # backward-compat.+ if interactive:+ return await self._process_task_with_snapshot(task)+if not validate_task_content(task.content, task.id):task.state = TaskState.FAILEDtask.result = "Task failed: Invalid or empty content provided"@@ -447,18 +792,194 @@ class Workforce(BaseNode):for sub in task.subtasksif sub.result)- task.state = TaskState.DONE+ if task.subtasks and all(+ sub.state == TaskState.DONE for sub in task.subtasks+ ):+ task.state = TaskState.DONE+ else:+ task.state = TaskState.FAILED- if subtasks:- task.result = "\n\n".join(- f"--- Subtask {sub.id} Result ---\n{sub.result}"- for sub in task.subtasks- if sub.result+ return task++ def process_task(self, task: Task) -> Task:+ r"""Synchronous wrapper for process_task that handles async operations+ internally.++ Args:+ task (Task): The task to be processed.++ Returns:+ Task: The updated task.++ Example:+ >>> workforce = Workforce("My Team")+ >>> task = Task(content="Analyze data", id="1")+ >>> result = workforce.process_task(task) # No async/await+ needed+ >>> print(result.result)+ """+ import asyncio+ import concurrent.futures++ # Check if we're already in an event loop+ try:+ asyncio.get_running_loop()++ # If we're in an event loop, we need to run in a thread+ def run_in_thread():+ # Create new event loop for this thread+ new_loop = asyncio.new_event_loop()+ asyncio.set_event_loop(new_loop)+ try:+ return new_loop.run_until_complete(+ self.process_task_async(task)+ )+ finally:+ new_loop.close()++ with concurrent.futures.ThreadPoolExecutor() as executor:+ future = executor.submit(run_in_thread)+ return future.result()++ except RuntimeError:+ # No event loop running, we can create one+ return asyncio.run(self.process_task_async(task))++ async def _process_task_with_snapshot(self, task: Task) -> Task:+ r"""Async version of process_task that supports human intervention.+ This method can be paused, resumed, and allows task modification.++ Args:+ task (Task): The task to be processed.++ Returns:+ Task: The updated task.+ """++ if not validate_task_content(task.content, task.id):+ task.state = TaskState.FAILED+ task.result = "Task failed: Invalid or empty content provided"+ logger.warning(+ f"Task {task.id} rejected: Invalid or empty content. "+ f"Content preview: '{task.content[:50]}...'")- task.state = TaskState.DONE+ return task++ self.reset()+ self._task = task+ self._state = WorkforceState.RUNNING+ task.state = TaskState.OPEN+ self._pending_tasks.append(task)++ # Decompose the task into subtasks first+ subtasks = self._decompose_task(task)+ self._pending_tasks.extendleft(reversed(subtasks))+ self.set_channel(TaskChannel())++ # Save initial snapshot+ self.save_snapshot("Initial task decomposition")++ try:+ await self.start()+ except Exception as e:+ logger.error(f"Error in workforce execution: {e}")+ self._state = WorkforceState.STOPPED+ raise+ finally:+ if self._state != WorkforceState.STOPPED:+ self._state = WorkforceState.IDLEreturn task+ def _process_task_with_intervention(self, task: Task) -> Task:+ r"""Process task with human intervention support. This creates and+ manages its own event loop to allow for pausing/resuming functionality.++ Args:+ task (Task): The task to be processed.++ Returns:+ Task: The updated task.+ """+ # Create new event loop if none exists or if we need a fresh one+ try:+ self._loop = asyncio.get_event_loop()+ if self._loop.is_closed():+ self._loop = asyncio.new_event_loop()+ asyncio.set_event_loop(self._loop)+ except RuntimeError:+ self._loop = asyncio.new_event_loop()+ asyncio.set_event_loop(self._loop)++ try:+ return self._loop.run_until_complete(+ self._process_task_with_snapshot(task)+ )+ finally:+ # Decide whether to keep or close the loop+ if self._loop and not self._loop.is_closed():+ if self._state == WorkforceState.PAUSED:+ # Keep alive to support resume()+ logger.info(+ "Event loop kept alive for potential resume "+ "operations."+ )+ else:+ # No more tasks; shut everything down cleanly+ try:+ # Ensure all async generators are finished+ self._loop.run_until_complete(+ self._loop.shutdown_asyncgens()+ )+ except RuntimeError:+ # Loop already running elsewhere+ pass+ self._loop.close()++ def continue_from_pause(self) -> Optional[Task]:+ r"""Continue execution from a paused state. This reuses the+ existing event loop.++ Returns:+ Optional[Task]: The completed task if execution finishes, None if+ still running/paused.+ """+ if self._state != WorkforceState.PAUSED:+ logger.warning("Workforce is not in paused state.")+ return None++ if self._loop is None or self._loop.is_closed():+ logger.error("No active event loop available for resuming.")+ return None++ # Resume execution+ self.resume()++ try:+ # Continue the existing async task+ remaining_task = self._loop.run_until_complete(+ self._continue_execution()+ )+ return remaining_task+ except Exception as e:+ logger.error(f"Error continuing execution: {e}")+ self._state = WorkforceState.STOPPED+ return None++ async def _continue_execution(self) -> Optional[Task]:+ r"""Internal method to continue execution after pause."""+ try:+ await self._listen_to_channel()+ except Exception as e:+ logger.error(f"Error in continued execution: {e}")+ self._state = WorkforceState.STOPPED+ raise+ finally:+ if self._state != WorkforceState.STOPPED:+ self._state = WorkforceState.IDLE++ return self._task+@check_if_running(False)def add_single_agent_worker(self, description: str, worker: ChatAgent@@ -545,6 +1066,10 @@ class Workforce(BaseNode):self._children.append(workforce)return self+ async def _async_reset(self) -> None:+ r"""Async implementation of reset to run on the event loop."""+ self._pause_event.set()+@check_if_running(False)def reset(self) -> None:r"""Reset the workforce and all the child nodes under it. Can only@@ -556,7 +1081,7 @@ class Workforce(BaseNode):self._child_listening_tasks.clear()# Clear dependency trackingself._task_dependencies.clear()- self._completed_tasks.clear()+ self._completed_tasks = []self._assignees.clear()self._in_flight_tasks = 0self.coordinator_agent.reset()@@ -565,6 +1090,21 @@ class Workforce(BaseNode):for child in self._children:child.reset()+ # Reset intervention state+ self._state = WorkforceState.IDLE+ self._stop_requested = False+ # Handle asyncio.Event in a thread-safe way+ if self._loop and not self._loop.is_closed():+ # If we have a loop, use it to set the event safely+ asyncio.run_coroutine_threadsafe(+ self._async_reset(), self._loop+ ).result()+ else:+ try:+ self._reset_task = asyncio.create_task(self._async_reset())+ except RuntimeError:+ asyncio.run(self._async_reset())+if hasattr(self, 'logger') and self.metrics_logger is not None:self.metrics_logger.reset_task_data()else:@@ -640,8 +1180,6 @@ class Workforce(BaseNode):async def _post_task(self, task: Task, assignee_id: str) -> None:# Record the start time when a task is posted- import time-self._task_start_times[task.id] = time.time()if self.metrics_logger:@@ -728,9 +1266,21 @@ class Workforce(BaseNode):async def _get_returned_task(self) -> Task:r"""Get the task that's published by this node and just get returned- from the assignee.+ from the assignee. Includes timeout handling to prevent indefinite+ waiting."""- return await self._channel.get_returned_task_by_publisher(self.node_id)+ try:+ # Add timeout to prevent indefinite waiting+ return await asyncio.wait_for(+ self._channel.get_returned_task_by_publisher(self.node_id),+ timeout=300.0, # 5 minute timeout+ )+ except asyncio.TimeoutError:+ logger.warning(+ f"Timeout waiting for returned task in "+ f"workforce {self.node_id}"+ )+ raise ValueError("Timeout waiting for task to be returned")async def _post_ready_tasks(self) -> None:r"""Checks for unassigned tasks, assigns them, and then posts any@@ -777,7 +1327,8 @@ class Workforce(BaseNode):# Check if all dependencies for this task are in the completed# setif all(- dep_id in self._completed_tasks for dep_id in dependencies+ dep_id in {t.id for t in self._completed_tasks}+ for dep_id in dependencies):assignee_id = self._assignees[task.id]logger.debug(@@ -833,13 +1384,13 @@ class Workforce(BaseNode):parent_task_id=task.id,subtask_ids=[st.id for st in subtasks],)- for subtask_item in subtasks:+ for subtask in subtasks:self.metrics_logger.log_task_created(- task_id=subtask_item.id,- description=subtask_item.content,+ task_id=subtask.id,+ description=subtask.content,parent_task_id=task.id,- task_type=subtask_item.type,- metadata=subtask_item.additional_info,+ task_type=subtask.type,+ metadata=subtask.additional_info,)# Insert packets at the head of the queueself._pending_tasks.extendleft(reversed(subtasks))@@ -862,7 +1413,9 @@ class Workforce(BaseNode):f"Updating dependency state.")# Mark task as completed for dependency tracking- self._completed_tasks.add(task.id)+ self._completed_tasks.append(task)++ # Post next ready tasks# Sync shared memory after task completion to share knowledgeif self.share_memory:@@ -882,8 +1435,6 @@ class Workforce(BaseNode):token_usage = None# Get processing time from task start time or additional info- import time-if task.id in self._task_start_times:processing_time_seconds = (time.time() - self._task_start_times[task.id]@@ -927,19 +1478,44 @@ class Workforce(BaseNode):metadata={'current_state': task.state.value},)+ # Find and remove the completed task from pending tasks+ tasks_list = list(self._pending_tasks)+ found_and_removed = False++ for i, pending_task in enumerate(tasks_list):+ if pending_task.id == task.id:+ # Remove this specific task+ tasks_list.pop(i)+ self._pending_tasks = deque(tasks_list)+ found_and_removed = True+ print(+ f"{Fore.GREEN}โ Task {task.id} completed and removed "+ f"from queue.{Fore.RESET}"+ )+ break++ if not found_and_removed:+ # Task was already removed from pending queue (expected case when+ # it had been popped immediately after posting). No need to+ # draw user attention with a warning; record at debug level.+ logger.debug(+ f"Completed task {task.id} was already removed from pending "+ "queue."+ )+# Archive the task and update dependency trackingif task.id in self._assignees:await self._channel.archive_task(task.id)- logger.debug(f"Task {task.id} completed. Updating dependency state.")- # Mark task as completed for dependency tracking- self._completed_tasks.add(task.id)+ # Ensure it's in completed tasks set+ self._completed_tasks.append(task)- # are now completed.+ # Handle parent task completion logicparent = task.parent- if parent and parent.id not in self._completed_tasks:+ if parent and parent.id not in {t.id for t in self._completed_tasks}:all_subtasks_done = all(- sub.id in self._completed_tasks for sub in parent.subtasks+ sub.id in {t.id for t in self._completed_tasks}+ for sub in parent.subtasks)if all_subtasks_done:# Set the parent task state to done@@ -1012,10 +1588,12 @@ class Workforce(BaseNode):@check_if_running(False)async def _listen_to_channel(self) -> None:r"""Continuously listen to the channel, post task to the channel and- track the status of posted tasks.+ track the status of posted tasks. Now supports pause/resume and+ graceful stop."""self._running = True+ self._state = WorkforceState.RUNNINGlogger.info(f"Workforce {self.node_id} started.")await self._post_ready_tasks()@@ -1024,33 +1602,100 @@ class Workforce(BaseNode):self._task is Noneor self._pending_tasksor self._in_flight_tasks > 0- ):- returned_task = await self._get_returned_task()- self._in_flight_tasks -= 1- if returned_task.state == TaskState.DONE:- await self._handle_completed_task(returned_task)- elif returned_task.state == TaskState.FAILED:- halt = await self._handle_failed_task(returned_task)- if not halt:- continue- print(- f"{Fore.RED}Task {returned_task.id} has failed "- f"for 3 times, halting the workforce.{Fore.RESET}"- )- # Graceful shutdown instead of immediate break- await self._graceful_shutdown(returned_task)- break- elif returned_task.state == TaskState.OPEN:- # TODO: multi-layer workforce- pass- else:- raise ValueError(- f"Task {returned_task.id} has an unexpected state."- )+ ) and not self._stop_requested:+ try:+ # Check for pause request at the beginning of each loop+ # iteration+ await self._pause_event.wait()++ # Check for stop request after potential pause+ if self._stop_requested:+ logger.info("Stop requested, breaking execution loop.")+ break++ # Save snapshot before processing next task+ if self._pending_tasks:+ current_task = self._pending_tasks[0]+ # Throttled snapshot+ if (+ time.time() - self._last_snapshot_time+ >= self.snapshot_interval+ ):+ self.save_snapshot(+ f"Before processing task: {current_task.id}"+ )+ self._last_snapshot_time = time.time()++ # Get returned task (this may block until a task is returned)+ returned_task = await self._get_returned_task()+ self._in_flight_tasks -= 1++ # Check for stop request after getting task+ if self._stop_requested:+ logger.info("Stop requested after receiving task.")+ break++ # Process the returned task based on its state+ if returned_task.state == TaskState.DONE:+ print(+ f"{Fore.CYAN}๐ฏ Task {returned_task.id} completed "+ f"successfully.{Fore.RESET}"+ )+ await self._handle_completed_task(returned_task)+ elif returned_task.state == TaskState.FAILED:+ halt = await self._handle_failed_task(returned_task)+ if not halt:+ continue+ print(+ f"{Fore.RED}Task {returned_task.id} has failed "+ f"for 3 times, halting the workforce.{Fore.RESET}"+ )+ # Graceful shutdown instead of immediate break+ await self._graceful_shutdown(returned_task)+ break+ elif returned_task.state == TaskState.OPEN:+ # TODO: multi-layer workforce+ pass+ else:+ raise ValueError(+ f"Task {returned_task.id} has an unexpected state."+ )++ except Exception as e:+ logger.error(f"Error processing task: {e}")+ if self._stop_requested:+ break+ # Continue with next iteration unless stop is requested+ continue++ # Handle final state+ if self._stop_requested:+ self._state = WorkforceState.STOPPED+ logger.info("Workforce stopped by user request.")+ elif not self._pending_tasks and self._in_flight_tasks == 0:+ self._state = WorkforceState.IDLE+ logger.info("All tasks completed.")# shut down the whole workforce treeself.stop()+ def _submit_coro_to_loop(self, coro: 'Coroutine') -> None:+ r"""Thread-safe submission of coroutine to the workforce loop."""++ loop = self._loop+ if loop is None or loop.is_closed():+ logger.warning("Cannot submit coroutine - no active event loop")+ return+ try:+ running_loop = asyncio.get_running_loop()+ except RuntimeError:+ running_loop = None++ if running_loop is loop:+ loop.create_task(coro)+ else:+ asyncio.run_coroutine_threadsafe(coro, loop)+@check_if_running(False)async def start(self) -> None:r"""Start itself and all the child nodes under it."""@@ -1093,11 +1738,19 @@ class Workforce(BaseNode):"""# Create a new instance with the same configuration+ # Extract the original kwargs from the agents to properly clone them+ coordinator_kwargs = (+ getattr(self.coordinator_agent, 'init_kwargs', {}) or {}+ )+ task_kwargs = getattr(self.task_agent, 'init_kwargs', {}) or {}+new_instance = Workforce(description=self.description,- coordinator_agent_kwargs={},- task_agent_kwargs={},- new_worker_agent_kwargs=self.new_worker_agent_kwargs,+ coordinator_agent_kwargs=coordinator_kwargs.copy(),+ task_agent_kwargs=task_kwargs.copy(),+ new_worker_agent_kwargs=self.new_worker_agent_kwargs.copy()+ if self.new_worker_agent_kwargs+ else None,graceful_shutdown_timeout=self.graceful_shutdown_timeout,share_memory=self.share_memory,)@@ -1118,10 +1771,10 @@ class Workforce(BaseNode):child.description,child.assistant_role_name,child.user_role_name,+ child.chat_turn_limit,child.assistant_agent_kwargs,child.user_agent_kwargs,child.summarize_agent_kwargs,- child.chat_turn_limit,)elif isinstance(child, Workforce):new_instance.add_workforce(child.clone(with_memory))@@ -1335,9 +1988,9 @@ class Workforce(BaseNode):>>> for child in children:... print(f"{child['type']}: {child['description']}")"""- children_info = []+ children_info: List[Dict[str, Any]] = []for child in workforce_instance._children:- child_info = {+ child_info: Dict[str, Any] = {"node_id": child.node_id,"description": child.description,"type": type(child).__name__,diff --git a/docs/conf.py b/docs/conf.pyindex b3bb4fc74..ef2bb0561 100644--- a/docs/conf.py+++ b/docs/conf.py@@ -27,7 +27,7 @@ sys.path.insert(0, os.path.abspath('..'))project = 'CAMEL'copyright = '2024, CAMEL-AI.org'author = 'CAMEL-AI.org'-release = '0.2.66'+release = '0.2.67'html_favicon = ('https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png'diff --git a/docs/mintlify/reference/camel.societies.workforce.workforce.mdx b/docs/mintlify/reference/camel.societies.workforce.workforce.mdxindex e647e648c..3b9dcb2c1 100644--- a/docs/mintlify/reference/camel.societies.workforce.workforce.mdx+++ b/docs/mintlify/reference/camel.societies.workforce.workforce.mdx@@ -1,5 +1,40 @@<a id="camel.societies.workforce.workforce"></a>+<a id="camel.societies.workforce.workforce.WorkforceState"></a>++## WorkforceState++```python+class WorkforceState(Enum):+```++Workforce execution state for human intervention support.++<a id="camel.societies.workforce.workforce.WorkforceSnapshot"></a>++## WorkforceSnapshot++```python+class WorkforceSnapshot:+```++Snapshot of workforce state for resuming execution.++<a id="camel.societies.workforce.workforce.WorkforceSnapshot.__init__"></a>++### __init__++```python+def __init__(+ self,+ main_task: Optional[Task] = None,+ pending_tasks: Optional[Deque[Task]] = None,+ completed_tasks: Optional[List[Task]] = None,+ current_task_index: int = 0,+ description: str = ''+):+```+<a id="camel.societies.workforce.workforce.Workforce"></a>## Workforce@@ -105,6 +140,203 @@ def _decompose_task(self, task: Task):List[Task]: The subtasks.+<a id="camel.societies.workforce.workforce.Workforce.pause"></a>++### pause++```python+def pause(self):+```++Pause the workforce execution.++<a id="camel.societies.workforce.workforce.Workforce.resume"></a>++### resume++```python+def resume(self):+```++Resume the paused workforce execution.++<a id="camel.societies.workforce.workforce.Workforce.stop_gracefully"></a>++### stop_gracefully++```python+def stop_gracefully(self):+```++Request graceful stop of the workforce.++<a id="camel.societies.workforce.workforce.Workforce.save_snapshot"></a>++### save_snapshot++```python+def save_snapshot(self, description: str = ''):+```++Save current state as a snapshot.++<a id="camel.societies.workforce.workforce.Workforce.list_snapshots"></a>++### list_snapshots++```python+def list_snapshots(self):+```++List all available snapshots.++<a id="camel.societies.workforce.workforce.Workforce.get_pending_tasks"></a>++### get_pending_tasks++```python+def get_pending_tasks(self):+```++Get current pending tasks for human review.++<a id="camel.societies.workforce.workforce.Workforce.get_completed_tasks"></a>++### get_completed_tasks++```python+def get_completed_tasks(self):+```++Get completed tasks.++<a id="camel.societies.workforce.workforce.Workforce.modify_task_content"></a>++### modify_task_content++```python+def modify_task_content(self, task_id: str, new_content: str):+```++Modify the content of a pending task.++<a id="camel.societies.workforce.workforce.Workforce.add_task"></a>++### add_task++```python+def add_task(+ self,+ content: str,+ task_id: Optional[str] = None,+ additional_info: str = '',+ insert_position: int = -1+):+```++Add a new task to the pending queue.++<a id="camel.societies.workforce.workforce.Workforce.remove_task"></a>++### remove_task++```python+def remove_task(self, task_id: str):+```++Remove a task from the pending queue.++<a id="camel.societies.workforce.workforce.Workforce.reorder_tasks"></a>++### reorder_tasks++```python+def reorder_tasks(self, task_ids: List[str]):+```++Reorder pending tasks according to the provided task IDs list.++<a id="camel.societies.workforce.workforce.Workforce.resume_from_task"></a>++### resume_from_task++```python+def resume_from_task(self, task_id: str):+```++Resume execution from a specific task.++<a id="camel.societies.workforce.workforce.Workforce.restore_from_snapshot"></a>++### restore_from_snapshot++```python+def restore_from_snapshot(self, snapshot_index: int):+```++Restore workforce state from a snapshot.++<a id="camel.societies.workforce.workforce.Workforce.get_workforce_status"></a>++### get_workforce_status++```python+def get_workforce_status(self):+```++Get current workforce status for human review.++<a id="camel.societies.workforce.workforce.Workforce.process_task"></a>++### process_task++```python+def process_task(self, task: Task):+```++The main entry point for the workforce to process a task. It will+start the workforce and all the child nodes under it, process the+task provided and return the updated task.++**Parameters:**++- **task** (Task): The task to be processed.++**Returns:**++ Task: The updated task.++<a id="camel.societies.workforce.workforce.Workforce.process_task_with_intervention"></a>++### process_task_with_intervention++```python+def process_task_with_intervention(self, task: Task):+```++Process task with human intervention support. This creates and manages+its own event loop to allow for pausing/resuming functionality.++**Parameters:**++- **task** (Task): The task to be processed.++**Returns:**++ Task: The updated task.++<a id="camel.societies.workforce.workforce.Workforce.continue_from_pause"></a>++### continue_from_pause++```python+def continue_from_pause(self):+```++**Returns:**++ Optional[Task]: The completed task if execution finishes, None if still running/paused.+<a id="camel.societies.workforce.workforce.Workforce.add_single_agent_worker"></a>### add_single_agent_workerdiff --git a/examples/workforce/eigent.py b/examples/workforce/eigent.pyindex 3b5aea44a..eace7c4b6 100644--- a/examples/workforce/eigent.py+++ b/examples/workforce/eigent.py@@ -387,8 +387,22 @@ async def main():id='0',)- task = await workforce.process_task(human_task)- print('Final Result of Original task:\n', task.result)+ workforce.process_task(human_task)++ # Test WorkforceLogger features+ print("\n--- Workforce Log Tree ---")+ print(workforce.get_workforce_log_tree())++ print("\n--- Workforce KPIs ---")+ kpis = workforce.get_workforce_kpis()+ for key, value in kpis.items():+ print(f"{key}: {value}")++ log_file_path = "eigent_logs.json"+ print(f"\n--- Dumping Workforce Logs to {log_file_path} ---")+ workforce.dump_workforce_logs(log_file_path)+ print(f"Logs dumped. Please check the file: {log_file_path}")+finally:await playwright_toolkit.disconnect() # Disconnect the same instancediff --git a/examples/workforce/hackathon_judges.py b/examples/workforce/hackathon_judges.pyindex 55b2538fa..e845e98cc 100644--- a/examples/workforce/hackathon_judges.py+++ b/examples/workforce/hackathon_judges.py@@ -11,7 +11,6 @@# See the License for the specific language governing permissions and# limitations under the License.# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========-import asyncioimport textwrapfrom camel.agents import ChatAgent@@ -58,7 +57,7 @@ def make_judge(return agent-async def main():+def main():proj_content = textwrap.dedent("""\Project name: CAMEL-Powered Adaptive Learning Assistant@@ -252,7 +251,7 @@ async def main():worker=researcher_agent,)- await workforce.process_task(task)+ workforce.process_task(task)# Test WorkforceLogger featuresprint("\n--- Workforce Log Tree ---")@@ -270,7 +269,7 @@ async def main():if __name__ == "__main__":- asyncio.run(main())+ main()'''===============================================================================diff --git a/examples/workforce/human_in_the_loop/simple_hotkey_demo.py b/examples/workforce/human_in_the_loop/simple_hotkey_demo.pynew file mode 100644index 000000000..b6713d311--- /dev/null+++ b/examples/workforce/human_in_the_loop/simple_hotkey_demo.py@@ -0,0 +1,227 @@+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========++import asyncio+import threading+import time++from camel.agents.chat_agent import ChatAgent+from camel.messages.base import BaseMessage+from camel.models import ModelFactory+from camel.societies.workforce import Workforce+from camel.tasks.task import Task+from camel.toolkits import FileWriteToolkit, ThinkingToolkit+from camel.types import ModelPlatformType, ModelType+++def create_simple_workforce():+ r"""Create a simple workforce for demonstration."""+ thinking_toolkit = ThinkingToolkit()+ file_write_toolkit = FileWriteToolkit()++ # Create a simple search agent+ poet_agent = ChatAgent(+ system_message=BaseMessage.make_assistant_message(+ role_name="Poet Agent",+ content=(+ "You are a poet.Before you write the poem, you need "+ "to think about the poem and the content."+ ),+ ),+ model=ModelFactory.create(+ model_platform=ModelPlatformType.DEFAULT,+ model_type=ModelType.DEFAULT,+ ),+ tools=[*thinking_toolkit.get_tools()],+ )++ # Create a file write agent+ file_write_agent = ChatAgent(+ system_message=BaseMessage.make_assistant_message(+ role_name="File Write Agent",+ content="You are a file write agent.",+ ),+ model=ModelFactory.create(+ model_platform=ModelPlatformType.DEFAULT,+ model_type=ModelType.DEFAULT,+ ),+ tools=[*file_write_toolkit.get_tools()],+ )++ workforce = Workforce('Simple Demo Workforce')+ workforce.add_single_agent_worker("Poet Agent", poet_agent)+ workforce.add_single_agent_worker("File Write Agent", file_write_agent)++ return workforce+++def simple_intervention_menu(workforce: Workforce):+ """Simple intervention menu for quick operations."""+ while True:+ print("\n๐ฎ INTERVENTION MODE")+ print("Select an option:")+ print(" 1. Show pending/completed tasks")+ print(" 2. Modify a task")+ print(" 3. Add a new task")+ print(" 4. Resume execution")+ print(" 5. Stop workforce")++ try:+ choice = input("\nEnter choice (1-5): ").strip()++ if choice == "1":+ pending = workforce.get_pending_tasks()+ completed = workforce.get_completed_tasks()+ print(f"\n๐ Pending ({len(pending)}):")+ for i, task in enumerate(pending, 1):+ print(f" {i}. [{task.id}] {task.content}")+ print(f"\nโ Completed ({len(completed)}):")+ for i, task in enumerate(completed, 1):+ print(f" {i}. [{task.id}] {task.content}")++ # Show current workforce status+ status = workforce.get_workforce_status()+ print(+ f"\n๐ Status: {status['state']} | Pending: "+ f"{status['pending_tasks_count']} | Completed: "+ f"{status['completed_tasks_count']}"+ )++ elif choice == "2":+ pending = workforce.get_pending_tasks()+ if not pending:+ print("โ No pending tasks")+ continue+ print("\nPending tasks:")+ for i, task in enumerate(pending, 1):+ print(f" {i}. [{task.id}] {task.content}")+ try:+ num = int(input("Task number to modify: "))+ if 1 <= num <= len(pending):+ task = pending[num - 1]+ new_content = input("New content: ")+ if new_content.strip():+ workforce.modify_task_content(task.id, new_content)+ print("โ Modified!")+ except ValueError:+ print("โ Invalid number")++ elif choice == "3":+ content = input("New task content: ")+ if content.strip():+ task = workforce.add_task(content)+ print(f"โ Added task: {task.id}")++ elif choice == "4":+ print("โถ๏ธ Resuming...")+ return True++ elif choice == "5":+ print("๐ Stopping...")+ return False++ else:+ print("โ Invalid choice. Please enter 1-6.")++ except (KeyboardInterrupt, EOFError):+ print("\n๐ Enter 5 to resume or 6 to stop")+++def main():+ r"""Main demo function."""++ # Create workforce and task+ workforce = create_simple_workforce()+ task = Task(+ content=(+ "write a poem about the sun and the moon" "then write the md file"+ ),+ id="sun_and_moon",+ )++ print(f"๐ Task: {task.content}")+ print()++ # Start workforce in background+ def run_workforce():+ try:+ asyncio.run(workforce.process_task_async(task, interactive=True))+ print("\n๐ Task completed!")+ except Exception as e:+ print(f"\nโ Error: {e}")++ workforce_thread = threading.Thread(target=run_workforce)+ workforce_thread.daemon = True+ workforce_thread.start()++ print("โณ Waiting for initial task decomposition...")+ # Wait until workforce enters RUNNING state or timeout+ start_wait = time.time()+ while True:+ status = workforce.get_workforce_status()+ if status["state"] != "idle" or status["pending_tasks_count"] > 0:+ break+ if time.time() - start_wait > 10:+ print("โ ๏ธ Timed out waiting for workforce to start.")+ break+ time.sleep(0.2)++ print("๐ Workforce is running... Press 'h' + Enter to intervene!")++ # Input monitoring+ intervention_active = False++ while workforce_thread.is_alive():+ try:+ user_input = input().strip().lower()++ if user_input == 'h' and not intervention_active:+ intervention_active = True+ print("\nโธ๏ธ Pausing workforce...")+ workforce.pause()+ time.sleep(0.5)++ should_continue = simple_intervention_menu(workforce)++ if should_continue:+ workforce.resume()+ intervention_active = False+ print(+ "๐ Workforce resumed! Press 'h' + Enter to "+ "intervene again."+ )+ else:+ workforce.stop_gracefully()+ break++ except KeyboardInterrupt:+ print("\n๐ Force stopping...")+ workforce.stop_gracefully()+ break+ except EOFError:+ break++ workforce_thread.join(timeout=5)++ # Final status+ print("\n๐ Final Status:")+ status = workforce.get_workforce_status()+ for key, value in status.items():+ print(f" {key}: {value}")++ print("\n๐ Demo finished!")+++if __name__ == "__main__":+ main()diff --git a/examples/workforce/multiple_single_agents.py b/examples/workforce/multiple_single_agents.pyindex ac4ae56d8..a84f045aa 100644--- a/examples/workforce/multiple_single_agents.py+++ b/examples/workforce/multiple_single_agents.py@@ -11,9 +11,6 @@# See the License for the specific language governing permissions and# limitations under the License.# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========--import asyncio-from camel.agents.chat_agent import ChatAgentfrom camel.messages.base import BaseMessagefrom camel.models import ModelFactory@@ -23,7 +20,7 @@ from camel.toolkits import SearchToolkitfrom camel.types import ModelPlatformType, ModelType-async def main():+def main():# 1. Set up a Research agent with search toolssearch_agent = ChatAgent(system_message=BaseMessage.make_assistant_message(@@ -94,7 +91,7 @@ async def main():id='0',)- await workforce.process_task(human_task)+ workforce.process_task(human_task)# Test WorkforceLogger featuresprint("\n--- Workforce Log Tree ---")@@ -105,11 +102,11 @@ async def main():for key, value in kpis.items():print(f"{key}: {value}")- log_file_path = "hackathon_judges_logs.json"+ log_file_path = "multiple_single_agents_logs.json"print(f"\n--- Dumping Workforce Logs to {log_file_path} ---")workforce.dump_workforce_logs(log_file_path)print(f"Logs dumped. Please check the file: {log_file_path}")if __name__ == "__main__":- asyncio.run(main())+ main()diff --git a/examples/workforce/role_playing_with_agents.py b/examples/workforce/role_playing_with_agents.pyindex 9807ffbb4..a81303434 100644--- a/examples/workforce/role_playing_with_agents.py+++ b/examples/workforce/role_playing_with_agents.py@@ -12,7 +12,6 @@# limitations under the License.# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========-import asynciofrom camel.agents.chat_agent import ChatAgentfrom camel.messages.base import BaseMessage@@ -23,7 +22,7 @@ from camel.toolkits import GoogleMapsToolkit, SearchToolkit, WeatherToolkitfrom camel.types import ModelPlatformType, ModelType-async def main():+def main():guide_sysmsg = BaseMessage.make_assistant_message(role_name="tour guide",content="You have to lead everyone to have fun",@@ -78,7 +77,7 @@ async def main():content="research history of Paris and plan a tour.",id='0',)- await workforce.process_task(human_task)+ workforce.process_task(human_task)# Test WorkforceLogger featuresprint("\n--- Workforce Log Tree ---")@@ -89,11 +88,11 @@ async def main():for key, value in kpis.items():print(f"{key}: {value}")- log_file_path = "hackathon_judges_logs.json"+ log_file_path = "role_playing_with_agents_logs.json"print(f"\n--- Dumping Workforce Logs to {log_file_path} ---")workforce.dump_workforce_logs(log_file_path)print(f"Logs dumped. Please check the file: {log_file_path}")if __name__ == "__main__":- asyncio.run(main())+ main()diff --git a/pyproject.toml b/pyproject.tomlindex 6d1a2e503..a2f520977 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "hatchling.build"[project]name = "camel-ai"-version = "0.2.66"+version = "0.2.67"description = "Communicative Agents for AI Society Study"authors = [{ name = "CAMEL-AI.org" }]requires-python = ">=3.10,<3.13"@@ -173,7 +173,7 @@ dev_tools = ["tree-sitter>=0.23.2,<0.24","typer>=0.15.2","mcp>=1.3.0",- "daytona-sdk==0.14.0",+ "daytona-sdk>=0.20.0","aci-sdk>=1.0.0b1","langfuse>=2.60.5",]@@ -365,7 +365,7 @@ all = ["pyautogui>=0.9.54,<0.10","pyobvector>=0.1.18","scrapegraph-py>=1.12.0,<2",- "daytona-sdk==0.14.0",+ "daytona-sdk>=0.20.0","ibm-watsonx-ai>=1.3.11","google-genai>=1.13.0","aci-sdk>=1.0.0b1",diff --git a/uv.lock b/uv.lockindex 158fdfb8a..9f31516ad 100644--- a/uv.lock+++ b/uv.lock@@ -141,6 +141,18 @@ wheels = [{ url = "https://files.pythonhosted.org/packages/ab/47/151f657e429972916f61399bd52b410e9072d5a2cae1b794f890930e5797/aiohttp-3.12.12-cp312-cp312-win_amd64.whl", hash = "sha256:d1c1879b2e0fc337d7a1b63fe950553c2b9e93c071cf95928aeea1902d441403", size = 447863 },]+[[package]]+name = "aiohttp-retry"+version = "2.9.1"+source = { registry = "https://pypi.org/simple" }+dependencies = [+ { name = "aiohttp" },+]+sdist = { url = "https://files.pythonhosted.org/packages/9d/61/ebda4d8e3d8cfa1fd3db0fb428db2dd7461d5742cea35178277ad180b033/aiohttp_retry-2.9.1.tar.gz", hash = "sha256:8eb75e904ed4ee5c2ec242fefe85bf04240f685391c4879d8f541d6028ff01f1", size = 13608 }+wheels = [+ { url = "https://files.pythonhosted.org/packages/1a/99/84ba7273339d0f3dfa57901b846489d2e5c2cd731470167757f1935fffbd/aiohttp_retry-2.9.1-py3-none-any.whl", hash = "sha256:66d2759d1921838256a05a3f80ad7e724936f083e35be5abb5e16eed6be6dc54", size = 9981 },+]+[[package]]name = "aiomysql"version = "0.2.0"@@ -547,7 +559,7 @@ wheels = [[[package]]name = "camel-ai"-version = "0.2.66"+version = "0.2.67"source = { editable = "." }dependencies = [{ name = "colorama" },@@ -953,8 +965,8 @@ requires-dist = [{ name = "datasets", marker = "extra == 'all'", specifier = ">=3,<4" },{ name = "datasets", marker = "extra == 'huggingface'", specifier = ">=3,<4" },{ name = "datasets", marker = "extra == 'owl'", specifier = ">=3,<4" },- { name = "daytona-sdk", marker = "extra == 'all'", specifier = "==0.14.0" },- { name = "daytona-sdk", marker = "extra == 'dev-tools'", specifier = "==0.14.0" },+ { name = "daytona-sdk", marker = "extra == 'all'", specifier = ">=0.20.0" },+ { name = "daytona-sdk", marker = "extra == 'dev-tools'", specifier = ">=0.20.0" },{ name = "diffusers", marker = "extra == 'all'", specifier = ">=0.25.0,<0.26" },{ name = "diffusers", marker = "extra == 'huggingface'", specifier = ">=0.25.0,<0.26" },{ name = "discord-py", marker = "extra == 'all'", specifier = ">=2.3.2,<3" },@@ -1729,12 +1741,33 @@ wheels = [{ url = "https://files.pythonhosted.org/packages/0a/4c/bbe0bbe26bdb4edbdce09807202ab2281109efd15534912486e441bf7dff/daytona_api_client-0.20.1-py3-none-any.whl", hash = "sha256:4d5023108013365eba76bd0bd4704f30dee54c13e2ac5b62e8c88bcd4af5db92", size = 202997 },]+[[package]]+name = "daytona-api-client-async"+version = "0.20.1"+source = { registry = "https://pypi.org/simple" }+dependencies = [+ { name = "aiohttp" },+ { name = "aiohttp-retry" },+ { name = "pydantic" },+ { name = "python-dateutil" },+ { name = "typing-extensions" },+ { name = "urllib3" },+]+sdist = { url = "https://files.pythonhosted.org/packages/6e/e9/3496e82e36f999d81945acdd1e11cda2dfe3e470d31af384f14a1f9992e1/daytona_api_client_async-0.20.1.tar.gz", hash = "sha256:043045cb173b0b53416c19a9e276124a5c4fe14209f409a8572ef1975240e53f", size = 71806 }+wheels = [+ { url = "https://files.pythonhosted.org/packages/68/b7/827bcf4e40b21b3ae3c0a0f31a81efec42476516f002c8c943d41696953e/daytona_api_client_async-0.20.1-py3-none-any.whl", hash = "sha256:f24e06e3ab6e554214ed064f1b4c8723356c76c14c69de9a73a6cad60a386127", size = 192394 },+]+[[package]]name = "daytona-sdk"-version = "0.14.0"+version = "0.20.0"source = { registry = "https://pypi.org/simple" }dependencies = [+ { name = "aiofiles" },+ { name = "aiohttp" },+ { name = "aiohttp-retry" },{ name = "daytona-api-client" },+ { name = "daytona-api-client-async" },{ name = "deprecated" },{ name = "environs" },{ name = "httpx" },@@ -1743,9 +1776,9 @@ dependencies = [{ name = "python-dateutil" },{ name = "urllib3" },]-sdist = { url = "https://files.pythonhosted.org/packages/66/2c/1b48a7343168802dc9ae60d4bf5cda75c4755ca7fab39a444df2bcbaf3be/daytona_sdk-0.14.0.tar.gz", hash = "sha256:1df3eaa664dc793a33690a2361cf5262713ca5ff1f1c5730eb00b4940f11b6e8", size = 41874 }+sdist = { url = "https://files.pythonhosted.org/packages/77/dd/ed663b652cf62f089253e660c8c2f8b8ca5e45acecae385921a16cef9fdd/daytona_sdk-0.20.0.tar.gz", hash = "sha256:b5c13b999fcce1e6460974dbbb0dd336d8ca1e96d6a25afe705f476fba4e6f11", size = 68472 }wheels = [- { url = "https://files.pythonhosted.org/packages/47/ae/8ff649b3aa26ee2dbbf2f1243f7f17ca0b39e2c899d3d946a416313e3ee9/daytona_sdk-0.14.0-py3-none-any.whl", hash = "sha256:a6e5c8d56b8d2342a1a630de93b7346ce2a6bc81cb21a928988964a7b3ce7b0d", size = 46536 },+ { url = "https://files.pythonhosted.org/packages/35/98/7692c1b28bec6511a5c2eedad7de06d973fb6529384034ddc4a2b23cc3d3/daytona_sdk-0.20.0-py3-none-any.whl", hash = "sha256:7919acfff21c072a0ea826a3b250c0d9c5765e58c054d2bd5b91ea76f0df4709", size = 83754 },][[package]]