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:
2026-05-14 21:11:23 +02:00
parent 74a52ba6a3
commit 23a9dd7990
4 changed files with 19 additions and 19 deletions
+8 -8
View File
@@ -39,7 +39,7 @@ class PromptBuilder:
current = memory.stm.workflow.current
if current is 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]:
"""
@@ -149,12 +149,12 @@ EXPRESSIONS À UTILISER (une par situation, naturellement intégrées dans ta r
current = memory.stm.workflow.current or {}
lines = [
f"WORKFLOW SCOPE: active — {current.get('type')} "
f"WORKFLOW SCOPE: active — {current.get('name')} "
f"(stage: {current.get('stage')})",
]
target = current.get("target")
if target:
lines.append(f" Params: {target}")
params = current.get("params")
if params:
lines.append(f" Params: {params}")
wf_desc = (workflow.get("description") or "").strip()
if 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:
workflow = memory.stm.current_workflow
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"):
lines.append(f" Target: {workflow.get('target')}")
if workflow.get("params"):
lines.append(f" Params: {workflow.get('params')}")
if memory.stm.current_topic:
lines.append(f"CURRENT TOPIC: {memory.stm.current_topic}")
+3 -3
View File
@@ -44,10 +44,10 @@ def start_workflow(workflow_name: str, params: dict) -> dict[str, Any]:
"status": "error",
"error": "workflow_already_active",
"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."
),
"active_workflow": current.get("type"),
"active_workflow": current.get("name"),
}
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.",
}
workflow_name = current.get("type")
workflow_name = current.get("name")
memory.stm.end_workflow()
memory.save()
logger.info(f"end_workflow: '{workflow_name}' reason={reason!r}")
@@ -11,14 +11,14 @@ logger = logging.getLogger(__name__)
class Workflow:
current: dict | None = None
def start(self, workflow_type: str, target: dict) -> None:
def start(self, workflow_name: str, params: dict) -> None:
self.current = {
"type": workflow_type,
"target": target,
"name": workflow_name,
"params": params,
"stage": "started",
"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:
if self.current:
@@ -27,7 +27,7 @@ class Workflow:
def end(self) -> None:
if self.current:
logger.info(f"Workflow: Ended '{self.current.get('type')}'")
logger.info(f"Workflow: Ended '{self.current.get('name')}'")
self.current = None
def clear(self) -> None:
@@ -45,7 +45,7 @@ class Workflow:
"Write to start, advance, or end a workflow as you execute steps."
),
"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]:
return self.conversation.recent(n)
def start_workflow(self, workflow_type: str, target: dict) -> None:
self.workflow.start(workflow_type, target)
def start_workflow(self, workflow_name: str, params: dict) -> None:
self.workflow.start(workflow_name, params)
def update_workflow_stage(self, stage: str) -> None:
self.workflow.update_stage(stage)