Skip to content

Commit 262a1ed

Browse files
author
camel-docs-bot
committed
Auto-update documentation after merge [skip ci]
1 parent 07462e4 commit 262a1ed

File tree

5 files changed

+351
-33
lines changed

5 files changed

+351
-33
lines changed

docs/mintlify/reference/camel.agents.chat_agent.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,31 @@ response_format was provided.
897897
See Also:
898898
:meth:`asummarize`: Async version for non-blocking LLM calls.
899899

900+
<a id="camel.agents.chat_agent.ChatAgent._build_conversation_text_from_messages"></a>
901+
902+
### _build_conversation_text_from_messages
903+
904+
```python
905+
def _build_conversation_text_from_messages(self, messages: List[Any], include_summaries: bool = False):
906+
```
907+
908+
Build conversation text from messages for summarization.
909+
910+
This is a shared helper method that converts messages to a formatted
911+
conversation text string, handling tool calls, tool results, and
912+
regular messages.
913+
914+
**Parameters:**
915+
916+
- **messages** (List[Any]): List of messages to convert.
917+
- **include_summaries** (bool): Whether to include messages starting with [CONTEXT_SUMMARY]. (default: :obj:`False`)
918+
919+
**Returns:**
920+
921+
tuple[str, List[str]]: A tuple containing:
922+
- Formatted conversation text
923+
- List of user messages extracted from the conversation
924+
900925
<a id="camel.agents.chat_agent.ChatAgent.clear_memory"></a>
901926

902927
### clear_memory

docs/mintlify/reference/camel.societies.workforce.utils.mdx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,56 @@
11
<a id="camel.societies.workforce.utils"></a>
22

3+
<a id="camel.societies.workforce.utils.is_generic_role_name"></a>
4+
5+
## is_generic_role_name
6+
7+
```python
8+
def is_generic_role_name(role_name: str):
9+
```
10+
11+
Check if a role name is generic and should trigger fallback logic.
12+
13+
Generic role names are common, non-specific identifiers that don't
14+
provide meaningful information about an agent's actual purpose.
15+
When a role name is generic, fallback logic should be used to find
16+
a more specific identifier (e.g., from LLM-generated agent_title
17+
or description).
18+
19+
**Parameters:**
20+
21+
- **role_name** (str): The role name to check (will be converted to lowercase for case-insensitive comparison).
22+
23+
**Returns:**
24+
25+
bool: True if the role name is generic, False otherwise.
26+
27+
<a id="camel.societies.workforce.utils.WorkflowMetadata"></a>
28+
29+
## WorkflowMetadata
30+
31+
```python
32+
class WorkflowMetadata(BaseModel):
33+
```
34+
35+
Pydantic model for workflow metadata tracking.
36+
37+
This model defines the formal schema for workflow metadata that tracks
38+
versioning, timestamps, and contextual information about saved workflows.
39+
Used to maintain workflow history and enable proper version management.
40+
41+
<a id="camel.societies.workforce.utils.WorkflowConfig"></a>
42+
43+
## WorkflowConfig
44+
45+
```python
46+
class WorkflowConfig(BaseModel):
47+
```
48+
49+
Configuration for workflow memory management.
50+
51+
Centralizes all workflow-related configuration options to avoid scattered
52+
settings across multiple files and methods.
53+
354
<a id="camel.societies.workforce.utils.WorkerConf"></a>
455

556
## WorkerConf

docs/mintlify/reference/camel.societies.workforce.workflow_memory_manager.mdx

Lines changed: 201 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ workflow management concerns from the core worker task processing logic.
3737
- **worker** (ChatAgent): The worker agent that will use workflows.
3838
- **description** (str): Description of the worker's role.
3939
- **context_utility** (Optional[ContextUtility]): Shared context utility for workflow operations. If None, creates a new instance.
40+
- **role_identifier** (Optional[str]): Role identifier for organizing workflows by role. If provided, workflows will be stored in role-based folders. If None, uses default workforce context.
41+
- **config** (Optional[WorkflowConfig]): Configuration for workflow management. If None, uses default configuration.
4042

4143
<a id="camel.societies.workforce.workflow_memory_manager.WorkflowMemoryManager.__init__"></a>
4244

@@ -47,7 +49,9 @@ def __init__(
4749
self,
4850
worker: ChatAgent,
4951
description: str,
50-
context_utility: Optional[ContextUtility] = None
52+
context_utility: Optional[ContextUtility] = None,
53+
role_identifier: Optional[str] = None,
54+
config: Optional[WorkflowConfig] = None
5155
):
5256
```
5357

@@ -61,6 +65,132 @@ def _get_context_utility(self):
6165

6266
Get context utility with lazy initialization.
6367

68+
Uses role-based context if role_identifier is set, otherwise falls
69+
back to default workforce shared context.
70+
71+
<a id="camel.societies.workforce.workflow_memory_manager.WorkflowMemoryManager._extract_existing_workflow_metadata"></a>
72+
73+
### _extract_existing_workflow_metadata
74+
75+
```python
76+
def _extract_existing_workflow_metadata(self, file_path: Path):
77+
```
78+
79+
Extract metadata from an existing workflow file for versioning.
80+
81+
This method reads the metadata section from an existing workflow
82+
markdown file to retrieve version number and creation timestamp,
83+
enabling proper version tracking when updating workflows.
84+
85+
**Parameters:**
86+
87+
- **file_path** (Path): Path to the existing workflow file.
88+
89+
**Returns:**
90+
91+
Optional[WorkflowMetadata]: WorkflowMetadata instance if file
92+
exists and metadata is successfully parsed, None otherwise.
93+
94+
<a id="camel.societies.workforce.workflow_memory_manager.WorkflowMemoryManager._try_role_based_loading"></a>
95+
96+
### _try_role_based_loading
97+
98+
```python
99+
def _try_role_based_loading(
100+
self,
101+
role_name: str,
102+
pattern: Optional[str],
103+
max_files_to_load: int,
104+
use_smart_selection: bool
105+
):
106+
```
107+
108+
Try loading workflows from role-based directory structure.
109+
110+
**Parameters:**
111+
112+
- **role_name** (str): Role name to load workflows from.
113+
- **pattern** (Optional[str]): Custom search pattern for workflow files.
114+
- **max_files_to_load** (int): Maximum number of workflow files to load.
115+
- **use_smart_selection** (bool): Whether to use agent-based selection.
116+
117+
**Returns:**
118+
119+
bool: True if workflows were successfully loaded, False otherwise.
120+
121+
<a id="camel.societies.workforce.workflow_memory_manager.WorkflowMemoryManager._try_session_based_loading"></a>
122+
123+
### _try_session_based_loading
124+
125+
```python
126+
def _try_session_based_loading(
127+
self,
128+
session_id: str,
129+
role_name: str,
130+
pattern: Optional[str],
131+
max_files_to_load: int,
132+
use_smart_selection: bool
133+
):
134+
```
135+
136+
Try loading workflows from session-based directory (deprecated).
137+
138+
**Parameters:**
139+
140+
- **session_id** (str): Workforce session ID to load from.
141+
- **role_name** (str): Role name (for deprecation warning).
142+
- **pattern** (Optional[str]): Custom search pattern for workflow files.
143+
- **max_files_to_load** (int): Maximum number of workflow files to load.
144+
- **use_smart_selection** (bool): Whether to use agent-based selection.
145+
146+
**Returns:**
147+
148+
bool: True if workflows were successfully loaded, False otherwise.
149+
150+
<a id="camel.societies.workforce.workflow_memory_manager.WorkflowMemoryManager._session_based_smart_loading"></a>
151+
152+
### _session_based_smart_loading
153+
154+
```python
155+
def _session_based_smart_loading(self, session_id: str, max_files_to_load: int):
156+
```
157+
158+
Load workflows from session using smart selection.
159+
160+
**Parameters:**
161+
162+
- **session_id** (str): Session ID to load from.
163+
- **max_files_to_load** (int): Maximum number of files to load.
164+
165+
**Returns:**
166+
167+
bool: True if workflows were loaded, False otherwise.
168+
169+
<a id="camel.societies.workforce.workflow_memory_manager.WorkflowMemoryManager._session_based_pattern_loading"></a>
170+
171+
### _session_based_pattern_loading
172+
173+
```python
174+
def _session_based_pattern_loading(
175+
self,
176+
pattern: Optional[str],
177+
session_id: str,
178+
max_files_to_load: int
179+
):
180+
```
181+
182+
Load workflows from session using pattern matching.
183+
184+
**Parameters:**
185+
186+
- **pattern** (Optional[str]): Pattern for file matching.
187+
- **session_id** (str): Session ID to load from.
188+
- **max_files_to_load** (int): Maximum number of files to load.
189+
190+
**Returns:**
191+
192+
bool: True if workflows were loaded, False otherwise.
193+
64194
<a id="camel.societies.workforce.workflow_memory_manager.WorkflowMemoryManager.load_workflows"></a>
65195

66196
### load_workflows
@@ -69,23 +199,54 @@ Get context utility with lazy initialization.
69199
def load_workflows(
70200
self,
71201
pattern: Optional[str] = None,
72-
max_files_to_load: int = 3,
202+
max_files_to_load: Optional[int] = None,
73203
session_id: Optional[str] = None,
74204
use_smart_selection: bool = True
75205
):
76206
```
77207

78208
Load workflow memories using intelligent agent-based selection.
79209

80-
This method uses the worker agent to intelligently select the most
81-
relevant workflows based on workflow information (title, description,
82-
tags) rather than simple filename pattern matching.
210+
This method first tries to load workflows from the role-based folder
211+
structure. If no workflows are found and session_id is provided, falls
212+
back to session-based loading (deprecated).
83213

84214
**Parameters:**
85215

86216
- **pattern** (Optional[str]): Legacy parameter for backward compatibility. When use_smart_selection=False, uses this pattern for file matching. Ignored when smart selection is enabled.
87-
- **max_files_to_load** (int): Maximum number of workflow files to load. (default: :obj:`3`)
88-
- **session_id** (Optional[str]): Specific workforce session ID to load from. If None, searches across all sessions. (default: :obj:`None`)
217+
- **max_files_to_load** (Optional[int]): Maximum number of workflow files to load. If None, uses config.default_max_files_to_load. (default: :obj:`None`)
218+
- **session_id** (Optional[str]): Deprecated. Specific workforce session ID to load from using legacy session-based organization. (default: :obj:`None`)
219+
- **use_smart_selection** (bool): Whether to use agent-based intelligent workflow selection. When True, uses workflow information and LLM to select most relevant workflows. When False, falls back to pattern matching. (default: :obj:`True`)
220+
221+
**Returns:**
222+
223+
bool: True if workflow memories were successfully loaded, False
224+
otherwise. Check logs for detailed error messages.
225+
226+
<a id="camel.societies.workforce.workflow_memory_manager.WorkflowMemoryManager.load_workflows_by_role"></a>
227+
228+
### load_workflows_by_role
229+
230+
```python
231+
def load_workflows_by_role(
232+
self,
233+
role_name: Optional[str] = None,
234+
pattern: Optional[str] = None,
235+
max_files_to_load: Optional[int] = None,
236+
use_smart_selection: bool = True
237+
):
238+
```
239+
240+
Load workflow memories from role-based directory structure.
241+
242+
This method loads workflows from the new role-based folder structure:
243+
workforce_workflows/\{role_name\}/*.md
244+
245+
**Parameters:**
246+
247+
- **role_name** (Optional[str]): Role name to load workflows from. If None, uses the worker's role_name or role_identifier.
248+
- **pattern** (Optional[str]): Custom search pattern for workflow files. Ignored when use_smart_selection=True.
249+
- **max_files_to_load** (Optional[int]): Maximum number of workflow files to load. If None, uses config.default_max_files_to_load. (default: :obj:`None`)
89250
- **use_smart_selection** (bool): Whether to use agent-based intelligent workflow selection. When True, uses workflow information and LLM to select most relevant workflows. When False, falls back to pattern matching. (default: :obj:`True`)
90251

91252
**Returns:**
@@ -177,6 +338,11 @@ def _find_workflow_files(self, pattern: Optional[str], session_id: Optional[str]
177338

178339
Find and return sorted workflow files matching the pattern.
179340

341+
.. note::
342+
Session-based workflow search will be deprecated in a future
343+
version. Consider using :meth:`_find_workflow_files_by_role` for
344+
role-based organization instead.
345+
180346
**Parameters:**
181347

182348
- **pattern** (Optional[str]): Custom search pattern for workflow files. If None, uses worker role_name to generate pattern.
@@ -187,6 +353,33 @@ Find and return sorted workflow files matching the pattern.
187353
List[str]: Sorted list of workflow file paths (empty if
188354
validation fails).
189355

356+
<a id="camel.societies.workforce.workflow_memory_manager.WorkflowMemoryManager._find_workflow_files_by_role"></a>
357+
358+
### _find_workflow_files_by_role
359+
360+
```python
361+
def _find_workflow_files_by_role(
362+
self,
363+
role_name: Optional[str] = None,
364+
pattern: Optional[str] = None
365+
):
366+
```
367+
368+
Find workflow files in role-based directory structure.
369+
370+
This method searches for workflows in the new role-based folder
371+
structure: workforce_workflows/\{role_name\}/*.md
372+
373+
**Parameters:**
374+
375+
- **role_name** (Optional[str]): Role name to search for. If None, uses the worker's role_name or role_identifier.
376+
- **pattern** (Optional[str]): Custom search pattern for workflow files. If None, searches for all workflow files in the role directory.
377+
378+
**Returns:**
379+
380+
List[str]: Sorted list of workflow file paths by modification time
381+
(most recent first).
382+
190383
<a id="camel.societies.workforce.workflow_memory_manager.WorkflowMemoryManager._collect_workflow_contents"></a>
191384

192385
### _collect_workflow_contents
@@ -287,7 +480,7 @@ def _generate_workflow_filename(self):
287480
**Returns:**
288481

289482
str: Sanitized filename without timestamp and without .md
290-
extension. Format: \{role_name\}_workflow
483+
extension. Format: \{role_name\}\{workflow_filename_suffix\}
291484

292485
<a id="camel.societies.workforce.workflow_memory_manager.WorkflowMemoryManager._prepare_workflow_prompt"></a>
293486

0 commit comments

Comments
 (0)