refactor(memory): rename workflow.target -> params, type -> name
The Workflow STM component stored an active workflow as
{type, target, stage, started_at}. Now that start_workflow takes a
workflow_name and a params dict, those keys match what they actually
hold:
type -> name (the YAML workflow name, e.g. media.organize_media)
target -> params (the dict passed to start_workflow)
ShortTermMemory.start_workflow parameters renamed accordingly. All
consumers (prompt builder workflow scope + STM context, start/end
workflow tools) updated.
This commit is contained in:
@@ -39,7 +39,7 @@ class PromptBuilder:
|
|||||||
current = memory.stm.workflow.current
|
current = memory.stm.workflow.current
|
||||||
if current is None:
|
if current is None:
|
||||||
return None
|
return None
|
||||||
return self.workflow_loader.get(current.get("type"))
|
return self.workflow_loader.get(current.get("name"))
|
||||||
|
|
||||||
def visible_tool_names(self) -> list[str]:
|
def visible_tool_names(self) -> list[str]:
|
||||||
"""
|
"""
|
||||||
@@ -149,12 +149,12 @@ EXPRESSIONS À UTILISER (une par situation, naturellement intégrées dans ta r
|
|||||||
|
|
||||||
current = memory.stm.workflow.current or {}
|
current = memory.stm.workflow.current or {}
|
||||||
lines = [
|
lines = [
|
||||||
f"WORKFLOW SCOPE: active — {current.get('type')} "
|
f"WORKFLOW SCOPE: active — {current.get('name')} "
|
||||||
f"(stage: {current.get('stage')})",
|
f"(stage: {current.get('stage')})",
|
||||||
]
|
]
|
||||||
target = current.get("target")
|
params = current.get("params")
|
||||||
if target:
|
if params:
|
||||||
lines.append(f" Params: {target}")
|
lines.append(f" Params: {params}")
|
||||||
wf_desc = (workflow.get("description") or "").strip()
|
wf_desc = (workflow.get("description") or "").strip()
|
||||||
if wf_desc:
|
if wf_desc:
|
||||||
lines.append(f" Goal: {wf_desc}")
|
lines.append(f" Goal: {wf_desc}")
|
||||||
@@ -220,10 +220,10 @@ EXPRESSIONS À UTILISER (une par situation, naturellement intégrées dans ta r
|
|||||||
if memory.stm.current_workflow:
|
if memory.stm.current_workflow:
|
||||||
workflow = memory.stm.current_workflow
|
workflow = memory.stm.current_workflow
|
||||||
lines.append(
|
lines.append(
|
||||||
f"CURRENT WORKFLOW: {workflow.get('type')} (stage: {workflow.get('stage')})"
|
f"CURRENT WORKFLOW: {workflow.get('name')} (stage: {workflow.get('stage')})"
|
||||||
)
|
)
|
||||||
if workflow.get("target"):
|
if workflow.get("params"):
|
||||||
lines.append(f" Target: {workflow.get('target')}")
|
lines.append(f" Params: {workflow.get('params')}")
|
||||||
|
|
||||||
if memory.stm.current_topic:
|
if memory.stm.current_topic:
|
||||||
lines.append(f"CURRENT TOPIC: {memory.stm.current_topic}")
|
lines.append(f"CURRENT TOPIC: {memory.stm.current_topic}")
|
||||||
|
|||||||
@@ -44,10 +44,10 @@ def start_workflow(workflow_name: str, params: dict) -> dict[str, Any]:
|
|||||||
"status": "error",
|
"status": "error",
|
||||||
"error": "workflow_already_active",
|
"error": "workflow_already_active",
|
||||||
"message": (
|
"message": (
|
||||||
f"Workflow '{current.get('type')}' is already active. "
|
f"Workflow '{current.get('name')}' is already active. "
|
||||||
"Call end_workflow before starting a new one."
|
"Call end_workflow before starting a new one."
|
||||||
),
|
),
|
||||||
"active_workflow": current.get("type"),
|
"active_workflow": current.get("name"),
|
||||||
}
|
}
|
||||||
|
|
||||||
memory.stm.start_workflow(workflow_name, params or {})
|
memory.stm.start_workflow(workflow_name, params or {})
|
||||||
@@ -74,7 +74,7 @@ def end_workflow(reason: str) -> dict[str, Any]:
|
|||||||
"message": "No workflow is currently active.",
|
"message": "No workflow is currently active.",
|
||||||
}
|
}
|
||||||
|
|
||||||
workflow_name = current.get("type")
|
workflow_name = current.get("name")
|
||||||
memory.stm.end_workflow()
|
memory.stm.end_workflow()
|
||||||
memory.save()
|
memory.save()
|
||||||
logger.info(f"end_workflow: '{workflow_name}' reason={reason!r}")
|
logger.info(f"end_workflow: '{workflow_name}' reason={reason!r}")
|
||||||
|
|||||||
@@ -11,14 +11,14 @@ logger = logging.getLogger(__name__)
|
|||||||
class Workflow:
|
class Workflow:
|
||||||
current: dict | None = None
|
current: dict | None = None
|
||||||
|
|
||||||
def start(self, workflow_type: str, target: dict) -> None:
|
def start(self, workflow_name: str, params: dict) -> None:
|
||||||
self.current = {
|
self.current = {
|
||||||
"type": workflow_type,
|
"name": workflow_name,
|
||||||
"target": target,
|
"params": params,
|
||||||
"stage": "started",
|
"stage": "started",
|
||||||
"started_at": datetime.now().isoformat(),
|
"started_at": datetime.now().isoformat(),
|
||||||
}
|
}
|
||||||
logger.info(f"Workflow: Started '{workflow_type}'")
|
logger.info(f"Workflow: Started '{workflow_name}'")
|
||||||
|
|
||||||
def update_stage(self, stage: str) -> None:
|
def update_stage(self, stage: str) -> None:
|
||||||
if self.current:
|
if self.current:
|
||||||
@@ -27,7 +27,7 @@ class Workflow:
|
|||||||
|
|
||||||
def end(self) -> None:
|
def end(self) -> None:
|
||||||
if self.current:
|
if self.current:
|
||||||
logger.info(f"Workflow: Ended '{self.current.get('type')}'")
|
logger.info(f"Workflow: Ended '{self.current.get('name')}'")
|
||||||
self.current = None
|
self.current = None
|
||||||
|
|
||||||
def clear(self) -> None:
|
def clear(self) -> None:
|
||||||
@@ -45,7 +45,7 @@ class Workflow:
|
|||||||
"Write to start, advance, or end a workflow as you execute steps."
|
"Write to start, advance, or end a workflow as you execute steps."
|
||||||
),
|
),
|
||||||
"fields": {
|
"fields": {
|
||||||
"current": "Active workflow dict with keys: type, target, stage, started_at. None if idle.",
|
"current": "Active workflow dict with keys: name, params, stage, started_at. None if idle.",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ class ShortTermMemory:
|
|||||||
def get_recent_history(self, n: int = 10) -> list[dict]:
|
def get_recent_history(self, n: int = 10) -> list[dict]:
|
||||||
return self.conversation.recent(n)
|
return self.conversation.recent(n)
|
||||||
|
|
||||||
def start_workflow(self, workflow_type: str, target: dict) -> None:
|
def start_workflow(self, workflow_name: str, params: dict) -> None:
|
||||||
self.workflow.start(workflow_type, target)
|
self.workflow.start(workflow_name, params)
|
||||||
|
|
||||||
def update_workflow_stage(self, stage: str) -> None:
|
def update_workflow_stage(self, stage: str) -> None:
|
||||||
self.workflow.update_stage(stage)
|
self.workflow.update_stage(stage)
|
||||||
|
|||||||
Reference in New Issue
Block a user