305999d8bf
- agent1.py : listener MQTT (agents/agent1/inbox), MAX_STEPS 10 - skills/plan.py : exécution séquentielle PLAN: avec contexte entre étapes - skills/schedule_tasks.py : SCHEDULE: / PLAN_LIST: / PLAN_CANCEL: via APScheduler - cli.py : interface CLI rich (MQTT, multi-agents, /plans, /agent) - system_prompt.txt : mis à jour avec tous les nouveaux skills Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
"""
|
|
Skill : PLAN
|
|
Exécute un plan de tâches séquentiel entre plusieurs agents.
|
|
Les résultats de chaque étape sont passés en contexte à la suivante.
|
|
|
|
Format :
|
|
PLAN: <agent> | <tâche> ;; <agent> | <tâche> ;; ...
|
|
|
|
Exemple :
|
|
PLAN: agent2_debian13 | Vérifier l'espace disque ;; agent2_debian13 | Nettoyer les paquets inutiles
|
|
"""
|
|
from pathlib import Path
|
|
|
|
SKILL_NAME = "plan"
|
|
TRIGGER = "PLAN:"
|
|
|
|
def execute(args: str) -> str:
|
|
from skills.delegate import execute as delegate_exec
|
|
|
|
steps_raw = [s.strip() for s in args.split(";;") if s.strip()]
|
|
if not steps_raw:
|
|
return "Erreur : plan vide. Format : PLAN: <agent> | <tâche> ;; <agent> | <tâche>"
|
|
|
|
steps = []
|
|
for s in steps_raw:
|
|
if "|" not in s:
|
|
return "Erreur étape «{}» : format attendu <agent> | <tâche>".format(s)
|
|
agent, _, task = s.partition("|")
|
|
steps.append((agent.strip(), task.strip()))
|
|
|
|
report = ["Plan d'exécution ({} étape(s)) :".format(len(steps))]
|
|
context = ""
|
|
|
|
for i, (agent, task) in enumerate(steps, 1):
|
|
full_task = task
|
|
if context:
|
|
full_task = "{}\n[Contexte étape précédente]\n{}".format(task, context)
|
|
|
|
report.append("\n── Étape {}/{} → [{}] ──".format(i, len(steps), agent))
|
|
result = delegate_exec("{} | {}".format(agent, full_task))
|
|
report.append(result)
|
|
context = result # passe le résultat à l'étape suivante
|
|
|
|
report.append("\n── Plan terminé ──")
|
|
return "\n".join(report)
|