🐫 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
Auto-update documentation after merge [skip ci]
camel-docs-botda5b5d4e25e7
diff --git a/docs/mintlify/reference/camel.agents.chat_agent.mdx b/docs/mintlify/reference/camel.agents.chat_agent.mdxindex 3f36c1f72..55a18f303 100644--- a/docs/mintlify/reference/camel.agents.chat_agent.mdx+++ b/docs/mintlify/reference/camel.agents.chat_agent.mdx@@ -1,5 +1,13 @@<a id="camel.agents.chat_agent"></a>+<a id="camel.agents.chat_agent._cleanup_temp_files"></a>++## _cleanup_temp_files++```python+def _cleanup_temp_files():+```+<a id="camel.agents.chat_agent.StreamContentAccumulator"></a>## StreamContentAccumulator@@ -239,7 +247,7 @@ Class for managing conversations of CAMEL Chat Agents.- **stop_event** (Optional[threading.Event], optional): Event to signal termination of the agent's operation. When set, the agent will terminate its execution. (default: :obj:`None`)- **tool_execution_timeout** (Optional[float], optional): Timeout for individual tool execution. If None, wait indefinitely.- **mask_tool_output** (Optional[bool]): Whether to return a sanitized placeholder instead of the raw tool output. (default: :obj:`False`)-- **pause_event** (Optional[asyncio.Event]): Event to signal pause of the agent's operation. When clear, the agent will pause its execution. (default: :obj:`None`)+- **pause_event** (Optional[Union[threading.Event, asyncio.Event]]): Event to signal pause of the agent's operation. When clear, the agent will pause its execution. Use threading.Event for sync operations or asyncio.Event for async operations. (default: :obj:`None`)- **prune_tool_calls_from_memory** (bool): Whether to clean tool call messages from memory after response generation to save token usage. When enabled, removes FUNCTION/TOOL role messages and ASSISTANT messages with tool_calls after each step. (default: :obj:`False`)- **retry_attempts** (int, optional): Maximum number of retry attempts for rate limit errors. (default: :obj:`3`)- **retry_delay** (float, optional): Initial delay in seconds between retries. Uses exponential backoff. (default: :obj:`1.0`)@@ -269,7 +277,7 @@ def __init__(stop_event: Optional[threading.Event] = None,tool_execution_timeout: Optional[float] = None,mask_tool_output: bool = False,- pause_event: Optional[asyncio.Event] = None,+ pause_event: Optional[Union[threading.Event, asyncio.Event]] = None,prune_tool_calls_from_memory: bool = False,retry_attempts: int = 3,retry_delay: float = 1.0,@@ -402,6 +410,23 @@ re-added to ensure it's not lost.- **value** (AgentMemory): The new agent memory to use.+<a id="camel.agents.chat_agent.ChatAgent.set_context_utility"></a>++### set_context_utility++```python+def set_context_utility(self, context_utility: Optional[ContextUtility]):+```++Set the context utility for the agent.++This allows external components (like SingleAgentWorker) to provide+a shared context utility instance for workflow management.++**Parameters:**++- **context_utility** (ContextUtility, optional): The context utility to use. If None, the agent will create its own when needed.+<a id="camel.agents.chat_agent.ChatAgent._get_full_tool_schemas"></a>### _get_full_tool_schemas@@ -584,6 +609,7 @@ def summarize(self,filename: Optional[str] = None,summary_prompt: Optional[str] = None,+ response_format: Optional[Type[BaseModel]] = None,working_directory: Optional[Union[str, Path]] = None):```@@ -595,12 +621,14 @@ to a markdown file.- **filename** (Optional[str]): The base filename (without extension) to use for the markdown file. Defaults to a timestamped name when not provided.- **summary_prompt** (Optional[str]): Custom prompt for the summarizer. When omitted, a default prompt highlighting key decisions, action items, and open questions is used.+- **response_format** (Optional[Type[BaseModel]]): A Pydantic model defining the expected structure of the response. If provided, the summary will be generated as structured output and included in the result.- **working_directory** (Optional[str|Path]): Optional directory to save the markdown summary file. If provided, overrides the default directory used by ContextUtility.**Returns:**Dict[str, Any]: A dictionary containing the summary text, file-path, and status message.+path, status message, and optionally structured_summary if+response_format was provided.<a id="camel.agents.chat_agent.ChatAgent.clear_memory"></a>@@ -637,6 +665,21 @@ def init_messages(self):Initializes the stored messages list with the current systemmessage.+<a id="camel.agents.chat_agent.ChatAgent.reset_to_original_system_message"></a>++### reset_to_original_system_message++```python+def reset_to_original_system_message(self):+```++Reset system message to original, removing any appended context.++This method reverts the agent's system message back to its original+state, removing any workflow context or other modifications that may+have been appended. Useful for resetting agent state in multi-turn+scenarios.+<a id="camel.agents.chat_agent.ChatAgent.record_message"></a>### record_message@@ -1163,9 +1206,8 @@ def _execute_tools_sync_with_status_accumulator():```-Execute multiple tools synchronously with-proper content accumulation, using threads+queue for-non-blocking status streaming.+Execute multiple tools synchronously with proper content+accumulation, using ThreadPoolExecutor for better timeout handling.<a id="camel.agents.chat_agent.ChatAgent._execute_tool_from_stream_data"></a>diff --git a/docs/mintlify/reference/camel.societies.workforce.single_agent_worker.mdx b/docs/mintlify/reference/camel.societies.workforce.single_agent_worker.mdxindex a13bff46a..37688012e 100644--- a/docs/mintlify/reference/camel.societies.workforce.single_agent_worker.mdx+++ b/docs/mintlify/reference/camel.societies.workforce.single_agent_worker.mdx@@ -87,6 +87,8 @@ A worker node that consists of a single agent.- **pool_max_size** (int): Maximum size of the agent pool. (default: :obj:`10`)- **auto_scale_pool** (bool): Whether to auto-scale the agent pool. (default: :obj:`True`)- **use_structured_output_handler** (bool, optional): Whether to use the structured output handler instead of native structured output. When enabled, the workforce will use prompts with structured output instructions and regex extraction to parse responses. This ensures compatibility with agents that don't reliably support native structured output. When disabled, the workforce uses the native response_format parameter. (default: :obj:`True`)+- **context_utility** (ContextUtility, optional): Shared context utility instance for workflow management. If provided, all workflow operations will use this shared instance instead of creating a new one. This ensures multiple workers share the same session directory. (default: :obj:`None`)+- **enable_workflow_memory** (bool, optional): Whether to enable workflow memory accumulation during task execution. When enabled, conversations from all task executions are accumulated for potential workflow saving. Set to True if you plan to call save_workflow_memories(). (default: :obj:`False`)<a id="camel.societies.workforce.single_agent_worker.SingleAgentWorker.__init__"></a>@@ -101,7 +103,9 @@ def __init__(pool_initial_size: int = 1,pool_max_size: int = 10,auto_scale_pool: bool = True,- use_structured_output_handler: bool = True+ use_structured_output_handler: bool = True,+ context_utility: Optional[ContextUtility] = None,+ enable_workflow_memory: bool = False):```@@ -115,6 +119,26 @@ def reset(self):Resets the worker to its initial state.+<a id="camel.societies.workforce.single_agent_worker.SingleAgentWorker._get_context_utility"></a>++### _get_context_utility++```python+def _get_context_utility(self):+```++Get context utility with lazy initialization.++<a id="camel.societies.workforce.single_agent_worker.SingleAgentWorker._get_conversation_accumulator"></a>++### _get_conversation_accumulator++```python+def _get_conversation_accumulator(self):+```++Get or create the conversation accumulator agent.+<a id="camel.societies.workforce.single_agent_worker.SingleAgentWorker.get_pool_stats"></a>### get_pool_stats@@ -124,3 +148,144 @@ def get_pool_stats(self):```Get agent pool statistics if pool is enabled.++<a id="camel.societies.workforce.single_agent_worker.SingleAgentWorker.save_workflow_memories"></a>++### save_workflow_memories++```python+def save_workflow_memories(self):+```++**Returns:**++ Dict[str, Any]: Result dictionary with keys:+- status (str): "success" or "error"+- summary (str): Generated workflow summary+- file_path (str): Path to saved file+- worker_description (str): Worker description used++<a id="camel.societies.workforce.single_agent_worker.SingleAgentWorker.load_workflow_memories"></a>++### load_workflow_memories++```python+def load_workflow_memories(+ self,+ pattern: Optional[str] = None,+ max_files_to_load: int = 3,+ session_id: Optional[str] = None+):+```++Load workflow memories matching worker description+from saved files.++This method searches for workflow memory files that match the worker's+description and loads them into the agent's memory using+ContextUtility.++**Parameters:**++- **pattern** (Optional[str]): Custom search pattern for workflow memory files. If None, uses worker description to generate pattern.+- **max_files_to_load** (int): Maximum number of workflow files to load. (default: :obj:`3`)+- **session_id** (Optional[str]): Specific workforce session ID to load from. If None, searches across all sessions. (default: :obj:`None`)++**Returns:**++ bool: True if workflow memories were successfully loaded, False+otherwise.++<a id="camel.societies.workforce.single_agent_worker.SingleAgentWorker._find_workflow_files"></a>++### _find_workflow_files++```python+def _find_workflow_files(self, pattern: Optional[str], session_id: Optional[str] = None):+```++Find and return sorted workflow files matching the pattern.++**Parameters:**++- **pattern** (Optional[str]): Custom search pattern for workflow files. If None, uses worker description to generate pattern.+- **session_id** (Optional[str]): Specific session ID to search in. If None, searches across all sessions.++**Returns:**++ List[str]: Sorted list of workflow file paths (empty if+validation fails).++<a id="camel.societies.workforce.single_agent_worker.SingleAgentWorker._load_workflow_files"></a>++### _load_workflow_files++```python+def _load_workflow_files(self, workflow_files: List[str], max_files_to_load: int):+```++Load workflow files and return count of successful loads.++**Parameters:**++- **workflow_files** (List[str]): List of workflow file paths to load.++**Returns:**++ int: Number of successfully loaded workflow files.++<a id="camel.societies.workforce.single_agent_worker.SingleAgentWorker._validate_workflow_save_requirements"></a>++### _validate_workflow_save_requirements++```python+def _validate_workflow_save_requirements(self):+```++**Returns:**++ Optional[Dict[str, Any]]: Error result dict if validation fails,+None if validation passes.++<a id="camel.societies.workforce.single_agent_worker.SingleAgentWorker._generate_workflow_filename"></a>++### _generate_workflow_filename++```python+def _generate_workflow_filename(self):+```++**Returns:**++ str: Sanitized filename without timestamp (session already has+timestamp).++<a id="camel.societies.workforce.single_agent_worker.SingleAgentWorker._prepare_workflow_prompt"></a>++### _prepare_workflow_prompt++```python+def _prepare_workflow_prompt(self):+```++**Returns:**++ str: Structured prompt for workflow summary.++<a id="camel.societies.workforce.single_agent_worker.SingleAgentWorker._select_agent_for_summarization"></a>++### _select_agent_for_summarization++```python+def _select_agent_for_summarization(self, context_util: ContextUtility):+```++Select the best agent for workflow summarization.++**Parameters:**++- **context_util**: Context utility to set on selected agent.++**Returns:**++ ChatAgent: Agent to use for summarization.diff --git a/docs/mintlify/reference/camel.societies.workforce.workforce.mdx b/docs/mintlify/reference/camel.societies.workforce.workforce.mdxindex 22a28def8..696faf651 100644--- a/docs/mintlify/reference/camel.societies.workforce.workforce.mdx+++ b/docs/mintlify/reference/camel.societies.workforce.workforce.mdx@@ -96,6 +96,18 @@ def __init__():```+<a id="camel.societies.workforce.workforce.Workforce._get_or_create_shared_context_utility"></a>++### _get_or_create_shared_context_utility++```python+def _get_or_create_shared_context_utility(self):+```++**Returns:**++ ContextUtility: The shared context utility instance.+<a id="camel.societies.workforce.workforce.Workforce._validate_agent_compatibility"></a>### _validate_agent_compatibility@@ -588,7 +600,8 @@ def add_single_agent_worker(self,description: str,worker: ChatAgent,- pool_max_size: int = DEFAULT_WORKER_POOL_SIZE+ pool_max_size: int = DEFAULT_WORKER_POOL_SIZE,+ enable_workflow_memory: bool = False):```@@ -600,6 +613,7 @@ Can be called when workforce is paused to dynamically add workers.- **description** (str): Description of the worker node.- **worker** (ChatAgent): The agent to be added.- **pool_max_size** (int): Maximum size of the agent pool. (default: :obj:`10`)+- **enable_workflow_memory** (bool): Whether to enable workflow memory accumulation. Set to True if you plan to call save_workflow_memories(). (default: :obj:`False`)**Returns:**@@ -669,6 +683,72 @@ def reset(self):Reset the workforce and all the child nodes under it. Can onlybe called when the workforce is not running.+<a id="camel.societies.workforce.workforce.Workforce.save_workflow_memories"></a>++### save_workflow_memories++```python+def save_workflow_memories(self):+```++**Returns:**++ Dict[str, str]: Dictionary mapping worker node IDs to save results.+Values are either file paths (success) or error messages+(failure).++<a id="camel.societies.workforce.workforce.Workforce.load_workflow_memories"></a>++### load_workflow_memories++```python+def load_workflow_memories(+ self,+ max_files_to_load: int = 3,+ session_id: Optional[str] = None+):+```++Load workflow memories for all SingleAgentWorker instances in the+workforce.++This method iterates through all child workers and loads relevant+workflow files for SingleAgentWorker instances using their+load_workflow_memories()+method. Workers match files based on their description names.++**Parameters:**++- **max_files_to_load** (int): Maximum number of workflow files to load per worker. (default: :obj:`3`)+- **session_id** (Optional[str]): Specific workforce session ID to load from. If None, searches across all sessions. (default: :obj:`None`)++**Returns:**++ Dict[str, bool]: Dictionary mapping worker node IDs to load+success status.+True indicates successful loading, False indicates failure.++<a id="camel.societies.workforce.workforce.Workforce._load_management_agent_workflows"></a>++### _load_management_agent_workflows++```python+def _load_management_agent_workflows(self, max_files_to_load: int, session_id: Optional[str] = None):+```++Load workflow summaries for coordinator and task planning agents.++This method loads aggregated workflow summaries to help:+- Coordinator agent: understand task assignment patterns and worker+capabilities+- Task agent: understand task decomposition patterns and+successful strategies++**Parameters:**++- **max_files_to_load** (int): Maximum number of workflow files to load.+- **session_id** (Optional[str]): Specific session ID to load from. If None, searches across all sessions.+<a id="camel.societies.workforce.workforce.Workforce.set_channel"></a>### set_channeldiff --git a/docs/mintlify/reference/camel.toolkits.context_summarizer_toolkit.mdx b/docs/mintlify/reference/camel.toolkits.context_summarizer_toolkit.mdxindex 63f6d62f0..c6b591a69 100644--- a/docs/mintlify/reference/camel.toolkits.context_summarizer_toolkit.mdx+++ b/docs/mintlify/reference/camel.toolkits.context_summarizer_toolkit.mdx@@ -92,7 +92,7 @@ including timestamp and session information.**Returns:**- str: Success message or error message.+ str: "success" or error message starting with "Error:".<a id="camel.toolkits.context_summarizer_toolkit.ContextSummarizerToolkit._save_history"></a>@@ -111,7 +111,7 @@ with message roles, agent IDs, and content structure preserved.**Returns:**- str: Success message or error message.+ str: "success" or error message starting with "Error:".<a id="camel.toolkits.context_summarizer_toolkit.ContextSummarizerToolkit._compress_and_save"></a>diff --git a/docs/mintlify/reference/camel.utils.context_utils.mdx b/docs/mintlify/reference/camel.utils.context_utils.mdxindex c7e420390..42c5022b0 100644--- a/docs/mintlify/reference/camel.utils.context_utils.mdx+++ b/docs/mintlify/reference/camel.utils.context_utils.mdx@@ -1,5 +1,31 @@<a id="camel.utils.context_utils"></a>+<a id="camel.utils.context_utils.WorkflowSummary"></a>++## WorkflowSummary++```python+class WorkflowSummary(BaseModel):+```++Pydantic model for structured workflow summaries.++This model defines the schema for workflow memories that can be reused+by future agents for similar tasks.++<a id="camel.utils.context_utils.WorkflowSummary.get_instruction_prompt"></a>++### get_instruction_prompt++```python+def get_instruction_prompt(cls):+```++**Returns:**++ str: The instruction prompt that guides agents to produce+structured output matching this schema.+<a id="camel.utils.context_utils.ContextUtility"></a>## ContextUtility@@ -20,13 +46,19 @@ Key features:- Text-based search through files- File metadata handling- Agent memory record retrieval+- Shared session management for workforce workflows<a id="camel.utils.context_utils.ContextUtility.__init__"></a>### __init__```python-def __init__(self, working_directory: Optional[str] = None):+def __init__(+ self,+ working_directory: Optional[str] = None,+ session_id: Optional[str] = None,+ create_folder: bool = True+):```Initialize the ContextUtility.@@ -34,17 +66,24 @@ Initialize the ContextUtility.**Parameters:**- **working_directory** (str, optional): The directory path where files will be stored. If not provided, a default directory will be used.+- **session_id** (str, optional): The session ID to use. If provided, this instance will use the same session folder as other instances with the same session_id. If not provided, a new session ID will be generated.+- **create_folder** (bool): Whether to create the session folder immediately. If False, the folder will be created only when needed (e.g., when saving files). Default is True for backward compatibility.<a id="camel.utils.context_utils.ContextUtility._setup_storage"></a>### _setup_storage```python-def _setup_storage(self, working_directory: Optional[str]):+def _setup_storage(+ self,+ working_directory: Optional[str],+ session_id: Optional[str] = None,+ create_folder: bool = True+):```-Initialize session-specific storage paths and create directory-structure for context file management.+Initialize session-specific storage paths and optionally create+directory structure for context file management.<a id="camel.utils.context_utils.ContextUtility._generate_session_id"></a>@@ -57,6 +96,16 @@ def _generate_session_id(self):Create timestamp-based unique identifier for isolatingcurrent session files from other sessions.+<a id="camel.utils.context_utils.ContextUtility._ensure_directory_exists"></a>++### _ensure_directory_exists++```python+def _ensure_directory_exists(self):+```++Ensure the working directory exists, creating it if necessary.+<a id="camel.utils.context_utils.ContextUtility._create_or_update_note"></a>### _create_or_update_note@@ -102,7 +151,35 @@ Generic method to save any markdown content to a file.**Returns:**- str: Success message or error message.+ str: "success" on success, error message starting with "Error:"+on failure.++<a id="camel.utils.context_utils.ContextUtility.structured_output_to_markdown"></a>++### structured_output_to_markdown++```python+def structured_output_to_markdown(+ self,+ structured_data: BaseModel,+ metadata: Optional[Dict[str, Any]] = None,+ title: Optional[str] = None,+ field_mappings: Optional[Dict[str, str]] = None+):+```++Convert any Pydantic BaseModel instance to markdown format.++**Parameters:**++- **structured_data**: Any Pydantic BaseModel instance+- **metadata**: Optional metadata to include in the markdown+- **title**: Optional custom title, defaults to model class name (default: model class name)+- **field_mappings**: Optional mapping of field names to custom section titles++**Returns:**++ str: Markdown formatted content<a id="camel.utils.context_utils.ContextUtility.load_markdown_file"></a>@@ -294,22 +371,98 @@ def get_session_id(self):str: The session ID.+<a id="camel.utils.context_utils.ContextUtility.set_session_id"></a>++### set_session_id++```python+def set_session_id(self, session_id: str):+```++Set a new session ID and update the working directory accordingly.++This allows sharing session directories between multiple ContextUtility+instances by using the same session_id.++**Parameters:**++- **session_id** (str): The session ID to use.+<a id="camel.utils.context_utils.ContextUtility.load_markdown_context_to_memory"></a>### load_markdown_context_to_memory```python-def load_markdown_context_to_memory(self, agent: 'ChatAgent', filename: str):+def load_markdown_context_to_memory(+ self,+ agent: 'ChatAgent',+ filename: str,+ include_metadata: bool = False+):```Load context from a markdown file and append it to agent memory.-Preserves existing conversation history without wiping it.**Parameters:**- **agent** (ChatAgent): The agent to append context to.- **filename** (str): Name of the markdown file (without .md extension).+- **include_metadata** (bool): Whether to include metadata section in the loaded content. Defaults to False.**Returns:**str: Status message indicating success or failure with details.++<a id="camel.utils.context_utils.ContextUtility._filter_metadata_from_content"></a>++### _filter_metadata_from_content++```python+def _filter_metadata_from_content(self, content: str):+```++Filter out metadata section from markdown content.++**Parameters:**++- **content** (str): The full markdown content including metadata.++**Returns:**++ str: Content with metadata section removed.++<a id="camel.utils.context_utils.ContextUtility.get_workforce_shared"></a>++### get_workforce_shared++```python+def get_workforce_shared(cls, session_id: Optional[str] = None):+```++Get or create shared workforce context utility with lazy init.++This method provides a centralized way to access shared context+utilities for workforce workflows, ensuring all workforce components+use the same session directory.++**Parameters:**++- **session_id** (str, optional): Custom session ID. If None, uses the default workforce session.++**Returns:**++ ContextUtility: Shared context utility instance for workforce.++<a id="camel.utils.context_utils.ContextUtility.reset_shared_sessions"></a>++### reset_shared_sessions++```python+def reset_shared_sessions(cls):+```++Reset shared sessions (useful for testing).++This method clears all shared session instances, forcing new ones+to be created on next access. Primarily used for testing to ensure+clean state between tests.