Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions skills/scripts/skills/incoherence/incoherence.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}]"
Expand All @@ -170,6 +170,10 @@ def format_incoherence_output(step, phase, agent_type, guidance):
)))
parts.append("")

if thoughts:
parts.append(f"<context>\n{thoughts}\n</context>")
parts.append("")

if step == 1:
parts.append("""<xml_format_mandate>
CRITICAL: All script outputs use XML format. You MUST:
Expand All @@ -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 \\"<ACCUMULATED_CONTEXT>\\"'
parts.append(render_invoke_after(InvokeAfterNode(cmd=next_cmd)))

return "\n".join(parts)
Expand Down Expand Up @@ -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)
Comment on lines 657 to 663

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. --thoughts not propagated 🐞 Bug ✓ Correctness

The PR adds --thoughts to argparse but the script never uses it and the generated next-step
command omits it. Many steps and the skill docs rely on --thoughts to carry state (dimension,
findings, resolutions), so following <invoke_after> will drop required context between steps.
Agent Prompt
### Issue description
`--thoughts` is parsed but never used or forwarded in the auto-generated next-step command, so workflow state is lost when following `<invoke_after>`.

### Issue Context
Many step action strings explicitly rely on `--thoughts` (“Your dimension is in --thoughts”, “invoke step N with … in --thoughts”), and SKILL.md documents it as required.

### Fix Focus Areas
- skills/scripts/skills/incoherence/incoherence.py[162-191]
- skills/scripts/skills/incoherence/incoherence.py[641-681]
- skills/incoherence/SKILL.md[13-19]

### Notes
Recommended approach:
1. Update `next_cmd` to include a thoughts placeholder, e.g.
   `python3 -m skills.incoherence.incoherence --step-number {step+1} --thoughts "<accumulated>"`
2. Optionally print the received `args.thoughts` (e.g., in a `<context>` block) so the agent can see what state it has.
3. Consider whether `--thoughts` should be `required=True` (or update SKILL.md to reflect optional usage), to avoid silently losing state.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Expand Down Expand Up @@ -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)

Expand Down