🐫 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-bot3dc8d3745f43
diff --git a/docs/mintlify/docs.json b/docs/mintlify/docs.jsonindex fbe680f26..91ad229b8 100644--- a/docs/mintlify/docs.json+++ b/docs/mintlify/docs.json@@ -655,6 +655,7 @@"reference/camel.utils.mcp_client","reference/camel.utils.message_summarizer","reference/camel.utils.response_format",+ "reference/camel.utils.stream_utils","reference/camel.utils.token_counting","reference/camel.utils.tool_result","reference/camel.utils.chunker.base",diff --git a/docs/mintlify/reference/camel.societies.workforce.worker.mdx b/docs/mintlify/reference/camel.societies.workforce.worker.mdxindex 26f2c1869..60db8683b 100644--- a/docs/mintlify/reference/camel.societies.workforce.worker.mdx+++ b/docs/mintlify/reference/camel.societies.workforce.worker.mdx@@ -48,6 +48,19 @@ def _get_dep_tasks_info(dependencies: List[Task]):def set_channel(self, channel: TaskChannel):```+<a id="camel.societies.workforce.worker.Worker.set_stream_callback"></a>++### set_stream_callback++```python+def set_stream_callback(+ self,+ stream_callback: Optional[Callable[['ChatAgentResponse', str, str], Optional[Awaitable[None]]]]+):+```++Set streaming callback for worker token/chunk updates.+<a id="camel.societies.workforce.worker.Worker.stop"></a>### stopdiff --git a/docs/mintlify/reference/camel.societies.workforce.workforce.mdx b/docs/mintlify/reference/camel.societies.workforce.workforce.mdxindex 517cb4a56..86c84fc56 100644--- a/docs/mintlify/reference/camel.societies.workforce.workforce.mdx+++ b/docs/mintlify/reference/camel.societies.workforce.workforce.mdx@@ -80,6 +80,7 @@ capabilities- **callbacks** (Optional[List[WorkforceCallback]], optional): A list of callback handlers to observe and record workforce lifecycle events and metrics (e.g., task creation/assignment/start/completion/ failure, worker creation/deletion, all-tasks-completed). All items must be instances of :class:`WorkforceCallback`, otherwise- **a**: class:`ValueError` is raised. If none of the provided callbacks implement :class:`WorkforceMetrics`, a built-in :class:`WorkforceLogger` (implements both callback and metrics) is added automatically. If at least one provided callback- **implements**: class:`WorkforceMetrics`, no default logger is added. (default: :obj:`None`)+- **stream_callback** (Optional[Callable], optional): Real-time callback for worker streaming output chunks. Called as `__INLINE_CODE_0____INLINE_CODE_1__None`)- **mode** (WorkforceMode, optional): The execution mode for task processing. AUTO_DECOMPOSE mode uses intelligent recovery strategies (decompose, replan, etc.) when tasks fail. PIPELINE mode uses simple retry logic and allows failed tasks to continue the workflow, passing error information to dependent tasks. (default: :obj:`WorkforceMode.AUTO_DECOMPOSE`)- **failure_handling_config** (Optional[Union[FailureHandlingConfig, Dict]]): Configuration for customizing failure handling behavior. Can be a FailureHandlingConfig instance or a dict with the same fields. Allows fine-grained control over which recovery strategies are enabled, maximum retry attempts, and whether to halt on max retries. The `enabled_strategies` field accepts both enum values and string lists like `["retry", "replan"]`. If None, uses default configuration with all strategies enabled. (default: :obj:`None`)@@ -111,6 +112,7 @@ def __init__(task_timeout_seconds: Optional[float] = None,mode: WorkforceMode = WorkforceMode.AUTO_DECOMPOSE,callbacks: Optional[List[WorkforceCallback]] = None,+ stream_callback: Optional[Callable[[str, str, str, str], Optional[Awaitable[None]]]] = None,failure_handling_config: Optional[Union[FailureHandlingConfig, Dict[str, Any]]] = None):```@@ -125,6 +127,35 @@ def _initialize_callbacks(self, callbacks: Optional[List[WorkforceCallback]]):Validate, register, and prime workforce callbacks.+<a id="camel.societies.workforce.workforce.Workforce._sync_child_stream_callbacks"></a>++### _sync_child_stream_callbacks++```python+def _sync_child_stream_callbacks(self):+```++Propagate stream callback settings to all child nodes.++<a id="camel.societies.workforce.workforce.Workforce.set_stream_callback"></a>++### set_stream_callback++```python+def set_stream_callback(+ self,+ stream_callback: Optional[Callable[[str, str, str, str], Optional[Awaitable[None]]]]+):+```++Set callback for real-time worker streaming output chunks.++Callback arguments:+worker_id (str): ID of the worker emitting this chunk.+task_id (str): ID of the task currently processed.+text (str): Incremental text content for this chunk.+mode (str): Chunk mode reported by model ("delta"/"accumulate").+<a id="camel.societies.workforce.workforce.Workforce._notify_worker_created"></a>### _notify_worker_created@@ -453,6 +484,14 @@ def _collect_shared_memory(self):records. Contains entries for 'coordinator', 'task_agent',and 'workers'.+<a id="camel.societies.workforce.workforce.Workforce._on_stream_callback"></a>++### _on_stream_callback++```python+def _on_stream_callback(self, chunk: ChatAgentResponse):+```+<a id="camel.societies.workforce.workforce.Workforce._share_memory_with_agents"></a>### _share_memory_with_agentsdiff --git a/docs/mintlify/reference/camel.utils.stream_utils.mdx b/docs/mintlify/reference/camel.utils.stream_utils.mdxnew file mode 100644index 000000000..053e34c29--- /dev/null+++ b/docs/mintlify/reference/camel.utils.stream_utils.mdx@@ -0,0 +1,89 @@+<a id="camel.utils.stream_utils"></a>++Utilities to detect and normalize streaming chat responses.++<a id="camel.utils.stream_utils._is_cumulative"></a>++## _is_cumulative++```python+def _is_cumulative(contents: list[str]):+```++Return True if each string is a prefix of the next one.++Streaming heuristic:+- Gather non-empty `__INLINE_CODE_0__` pieces.+- If each later piece strictly grows in length and starts with the+previous, treat as cumulative (covers `__INLINE_CODE_1__`) and+use the last piece.+- Otherwise concatenate pieces in order (covers delta streaming).++<a id="camel.utils.stream_utils._finalize_stream"></a>++## _finalize_stream++```python+def _finalize_stream(+ contents: list[str],+ final_response: Optional[ChatAgentResponse]+):+```++Normalize collected chunks into `__INLINE_CODE_0__`.++<a id="camel.utils.stream_utils._collect_sync_stream"></a>++## _collect_sync_stream++```python+def _collect_sync_stream(+ response: Any,+ stream_callback: Optional[Callable[[ChatAgentResponse], None]] = None+):+```++Collect chunks from a sync streaming response.++<a id="camel.utils.stream_utils.is_streaming_response"></a>++## is_streaming_response++```python+def is_streaming_response(response: Any):+```++Return True when the object represents a streaming sync response.++**Parameters:**++- **response**: Any object that might represent a chat response. Typically a `__INLINE_CODE_0____INLINE_CODE_1____INLINE_CODE_2__` attribute.++**Returns:**++ bool: `__INLINE_CODE_0__` if the object is detected as streaming according+to the heuristics above, otherwise `__INLINE_CODE_1__`.++<a id="camel.utils.stream_utils.consume_response_content"></a>++## consume_response_content++```python+def consume_response_content(+ response: Any,+ stream_callback: Optional[Callable[[ChatAgentResponse], None]] = None+):+```++Consume a sync response (streaming or not) into final_response, content.++**Parameters:**++- **response**: A complete `__INLINE_CODE_0__` or a streaming iterable of partial responses/chunks.+- **stream_callback**: Optional callable executed for each chunk as it is produced. The callback receives the current chunk and is intended for side effects such as logging or UI updates.++**Returns:**++ Tuple[Any, str]: The last chunk observed (or an empty+`__INLINE_CODE_0__` placeholder) and the assembled message+content string derived from the streamed pieces.