Fix format_completion_message counter and step display
This commit is contained in:
@@ -471,20 +471,27 @@ def format_completion_message(result: Dict) -> str:
|
||||
|
||||
plan = result["plan"]
|
||||
results = result.get("results", [])
|
||||
plan_steps = plan.get("steps", [])
|
||||
|
||||
msg = f"[OK] Concluido: {plan.get('task_name', 'Tarefa')}\n\n"
|
||||
|
||||
success_count = sum(1 for r in results if r.get("success"))
|
||||
total_count = len([r for r in results if r.get("step", 0) > 0])
|
||||
# Conta apenas resultados de passos reais (step > 0)
|
||||
real_results = [r for r in results if r.get("step", 0) > 0]
|
||||
success_count = sum(1 for r in real_results if r.get("success"))
|
||||
total_count = len(plan_steps)
|
||||
|
||||
msg += f"[STAT] Resultado: {success_count}/{total_count} passos executados com sucesso.\n\n"
|
||||
|
||||
for r in results:
|
||||
step_num = r.get("step", 0)
|
||||
if step_num > 0:
|
||||
status = "[OK]" if r.get("success") else "[FAIL]"
|
||||
output = r.get("output", "")[:500]
|
||||
msg += f"{status} Passo {step_num}:\n```\n{output}\n```\n\n"
|
||||
for step in plan_steps:
|
||||
step_num = step.get("order", 0)
|
||||
# Encontra resultado correspondente
|
||||
step_result = next((r for r in results if r.get("step") == step_num), None)
|
||||
if step_result:
|
||||
status_icon = "[OK]" if step_result.get("success") else "[FAIL]"
|
||||
output = step_result.get("output", "")[:500]
|
||||
msg += f"{status_icon} Passo {step_num}: {step.get('action', '')[:50]}\n"
|
||||
if output and not step_result.get("success"):
|
||||
msg += f" Erro: {output[:200]}\n"
|
||||
|
||||
return msg
|
||||
|
||||
|
||||
Reference in New Issue
Block a user