Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions commands/delegate.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ argument-hint: [task description]
allowed-tools: Agent, Task, EnterPlanMode, ExitPlanMode, AskUserQuestion, TaskCreate, TaskUpdate, TaskGet, TaskList, ToolSearch, TeamCreate, SendMessage
---

## RE-INVOCATION GUARD (READ FIRST)

Before doing ANYTHING else: if your most recent tool call in this conversation was `ExitPlanMode`, OR if you arrived here via a "PLAN ALREADY APPROVED" / "continuing to STAGE 1" continuation message, the plan is already approved. **Do NOT call `EnterPlanMode`. Do NOT re-enter Stage 0.** Skip directly to **STAGE 1: EXECUTION** — render the dependency graph from the approved plan in context and begin spawning Wave 0 agents. Re-entering plan mode here causes an infinite delegate→plan→approve loop.

Comment thread
qodo-code-review[bot] marked this conversation as resolved.
# Workflow Orchestrator System Prompt

## Purpose
Expand Down
9 changes: 7 additions & 2 deletions hooks/stop/python_stop_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,13 @@ def check_workflow_continuation() -> bool:
# This mimics ralph-wiggum's loop mechanism
output = {
"decision": "block",
"reason": "continue",
"systemMessage": "⚡ Workflow continuation: Proceeding to STAGE 1 execution.",
"reason": (
"PLAN ALREADY APPROVED. Execute Stage 1 NOW directly from the existing "
"approved plan in context. DO NOT call /workflow-orchestrator:delegate. "
"DO NOT call EnterPlanMode. DO NOT re-enter plan mode. "
"Render the dependency graph and start spawning Wave 0 agents."
),
"systemMessage": "⚡ Continuing to STAGE 1 execution (plan already approved).",
}
print(json.dumps(output)) # noqa: T201
logger.debug("Output block decision with 'continue' reason")
Comment on lines 173 to 185
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Action required

1. Continuation sentinel removed 🐞 Bug ≡ Correctness

python_stop_hook's continuation path is documented as injecting a special "continue" sentinel, but
the PR replaces the literal "reason": "continue" with a long instruction string while leaving
comments/logging that still assume a "continue" reason. If any downstream logic (or Claude Code hook
semantics) relies on the sentinel value, workflow auto-continuation may stop working or behave
inconsistently.
Agent Prompt
## Issue description
`hooks/stop/python_stop_hook.py` documents and logs that it "injects continue" / outputs a block decision with a "continue" reason, but the emitted JSON now sets `reason` to a long instruction string. If the continuation mechanism depends on the sentinel value (`reason == "continue"`), this change can break workflow continuation.

## Issue Context
This stop-hook path is triggered by `.claude/state/workflow_continuation_needed.json` written by `remind_skill_continuation.py` to force the session to continue after `ExitPlanMode`.

## Fix Focus Areas
- hooks/stop/python_stop_hook.py[152-186]
- hooks/stop/python_stop_hook.py[1-10]

## Suggested fix
- Set `output["reason"]` back to the literal sentinel value (e.g. `"continue"`) to preserve any sentinel-based contract.
- Move the new anti-loop guidance into `systemMessage` (or another non-sentinel field if supported) so the model still receives the explicit instructions.
- Update the surrounding comments/log line so they match the actual output (or vice-versa).

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

Comment on lines 173 to 185
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Action required

1. python_stop_hook.py hard-blocks tools 📘 Rule violation ☼ Reliability

The modified stop hook emits a hard-blocking response (decision: block) as part of its
continuation behavior. This violates the policy that only python_posttooluse_hook.py may
hard-block tool execution.
Agent Prompt
## Issue description
`hooks/stop/python_stop_hook.py` emits a hard-blocking decision (`decision: block`) in the continuation path, but policy allows only `python_posttooluse_hook.py` to hard-block tool execution.

## Issue Context
The PR updated the continuation `reason`/`systemMessage` text but left the stop hook in a hard-blocking mode. Compliance requires all other hooks to be advisory/non-blocking.

## Fix Focus Areas
- hooks/stop/python_stop_hook.py[172-186]

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

Expand Down
4 changes: 4 additions & 0 deletions system-prompts/orchestrator_stub.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Any user request that requires work — writing code, running tools, multi-step

The main agent does not execute work tools directly. Use only: Tasks API, AskUserQuestion, and `/workflow-orchestrator:delegate`. The delegate command loads the full orchestrator (planning, agent assignment, execution waves) on demand.

## Exception — continuation after plan approval

If your most recent tool call was `ExitPlanMode`, OR you received a "PLAN ALREADY APPROVED" / "continuing to STAGE 1" continuation message, **do NOT re-invoke `/workflow-orchestrator:delegate`** and **do NOT call `EnterPlanMode`** again. The orchestrator is already loaded and the plan is already approved — proceed directly to Stage 1 execution by rendering the dependency graph and spawning Wave 0 agents. The "all work → delegate" rule above does NOT apply during in-flight delegation.

## Team Mode

If `TeamCreate` is in your available tools, agent teams are enabled. When you run `/workflow-orchestrator:delegate`, default to team mode (`TeamCreate` + `Agent(team_name=...)`) for multi-agent work. If `TeamCreate` is not available, the delegate flow falls back to parallel subagents automatically.
Expand Down
Loading