diff --git a/skills/scripts/skills/incoherence/incoherence.py b/skills/scripts/skills/incoherence/incoherence.py
index de7227de..b3a5fc51 100755
--- a/skills/scripts/skills/incoherence/incoherence.py
+++ b/skills/scripts/skills/incoherence/incoherence.py
@@ -159,7 +159,7 @@
-def format_incoherence_output(step, phase, agent_type, guidance):
+def format_incoherence_output(step, phase, agent_type, guidance, thoughts=""):
"""Format output using AST builder API."""
parts = []
title = f"INCOHERENCE [{phase}] [{agent_type}]"
@@ -170,6 +170,10 @@ def format_incoherence_output(step, phase, agent_type, guidance):
)))
parts.append("")
+ if thoughts:
+ parts.append(f"\n{thoughts}\n")
+ parts.append("")
+
if step == 1:
parts.append("""
CRITICAL: All script outputs use XML format. You MUST:
@@ -183,10 +187,15 @@ def format_incoherence_output(step, phase, agent_type, guidance):
parts.append("")
next_text = guidance.get("next", "")
- if step >= total or "COMPLETE" in next_text.upper():
+ is_workflow_complete = step >= WORKFLOW.total_steps or next_text.strip().upper() == "WORKFLOW COMPLETE."
+ is_subagent_terminal = "SUB-AGENT TASK COMPLETE" in next_text.upper()
+
+ if is_workflow_complete:
parts.append("WORKFLOW COMPLETE - Present report to user.")
+ elif is_subagent_terminal:
+ parts.append("SUB-AGENT TASK COMPLETE - Return results to parent agent.")
else:
- next_cmd = f'python3 -m skills.incoherence.incoherence --step-number {step + 1}'
+ next_cmd = f'python3 -m skills.incoherence.incoherence --step-number {step + 1} --thoughts \\"\\"'
parts.append(render_invoke_after(InvokeAfterNode(cmd=next_cmd)))
return "\n".join(parts)
@@ -647,6 +656,8 @@ def main(
"""
parser = argparse.ArgumentParser(description="Incoherence Detector")
parser.add_argument("--step-number", type=int, required=True)
+ parser.add_argument("--thoughts", type=str, default="",
+ help="Accumulated context from previous steps")
args = parser.parse_args()
guidance = get_step_guidance(args.step_number, WORKFLOW.total_steps)
@@ -674,7 +685,7 @@ def main(
phase = "APPLICATION"
output = format_incoherence_output(
- args.step_number, phase, agent_type, guidance
+ args.step_number, phase, agent_type, guidance, thoughts=args.thoughts
)
print(output)