Skip to content

Commit 0723151

Browse files
committed
enhance summarization prompt, fallback to create if another mode is provided
1 parent 03894b4 commit 0723151

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

camel/societies/workforce/workflow_memory_manager.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,14 @@ def _create_error_result(message: str) -> Dict[str, Any]:
950950
workflow_summary, 'target_workflow_filename', None
951951
)
952952

953+
# validate operation_mode - default to create for unexpected values
954+
if operation_mode not in ("create", "update"):
955+
logger.warning(
956+
f"Unexpected operation_mode '{operation_mode}', "
957+
"defaulting to 'create'."
958+
)
959+
operation_mode = "create"
960+
953961
if operation_mode == "update":
954962
# if only one workflow loaded and no target specified,
955963
# assume agent meant that one
@@ -985,25 +993,16 @@ def _create_error_result(message: str) -> Dict[str, Any]:
985993
operation_mode = "create"
986994

987995
if operation_mode == "create":
988-
# use role-based filename
989-
# check if role_name or task_title for filename
990-
clean_name = self._get_sanitized_role_name()
991-
use_role_name = not is_generic_role_name(clean_name)
992-
993-
if use_role_name:
994-
# use explicit role name for filename
995-
base_filename = self._generate_workflow_filename()
996-
else:
997-
# use task_title from summary for filename
998-
task_title = workflow_summary.task_title
999-
clean_title = ContextUtility.sanitize_workflow_filename(
1000-
task_title
1001-
)
1002-
base_filename = (
1003-
f"{clean_title}{self.config.workflow_filename_suffix}"
1004-
if clean_title
1005-
else "workflow"
1006-
)
996+
# use task_title from summary for filename
997+
task_title = workflow_summary.task_title
998+
clean_title = ContextUtility.sanitize_workflow_filename(
999+
task_title
1000+
)
1001+
base_filename = (
1002+
f"{clean_title}{self.config.workflow_filename_suffix}"
1003+
if clean_title
1004+
else "workflow"
1005+
)
10071006

10081007
file_path = (
10091008
context_utility.get_working_directory()

camel/utils/context_utils.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ class WorkflowSummary(BaseModel):
117117
description=(
118118
"Whether to create a new workflow file or update an existing one. "
119119
"Use 'update' ONLY if you loaded a workflow that this task is a "
120-
"continuation, improvement, or refinement of. Use 'create' if "
121-
"this is a new/different task or if no workflows were loaded."
120+
"continuation, improvement, or refinement of AND the task_title "
121+
"should remain the same as the loaded workflow. Use 'create' if "
122+
"this is a new/different task, if the task_title would be "
123+
"different, or if no workflows were loaded."
122124
),
123125
default="create",
124126
)
@@ -161,9 +163,12 @@ def get_instruction_prompt(cls) -> str:
161163
'help future agents discover this workflow when working on '
162164
'similar tasks. '
163165
'For operation_mode, decide whether to update an existing '
164-
'workflow or create a new one. If you loaded a workflow that '
165-
'this task is a continuation or refinement of, set "update" and '
166-
'specify target_workflow_filename with the exact filename.'
166+
'workflow or create a new one. Use "update" ONLY if you loaded '
167+
'a workflow that this task is a continuation or refinement of '
168+
'AND the task_title should remain the same. If the task is '
169+
'different enough to warrant a different task_title, use "create" '
170+
'instead. When using "update", keep the same task_title as the '
171+
'loaded workflow and specify target_workflow_filename.'
167172
)
168173

169174

0 commit comments

Comments
 (0)