Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name": "workflow-orchestrator",
"source": "./",
"description": "Delegation system with workflow orchestration, specialized agents, and parallel execution for Claude Code",
"version": "2.0.0",
"version": "2.0.1",
"author": {
"name": "Nadav Barkai"
},
Expand Down
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "workflow-orchestrator",
"version": "2.0.0",
"version": "2.0.1",
"description": "Delegation system with workflow orchestration, specialized agents, and parallel execution for Claude Code",
"author": {
"name": "Nadav Barkai"
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file.

## [2.0.1] - 2026-04-12

### Fixed

- **Fix infinite delegate→plan-mode→approve loop.** After `ExitPlanMode`, the Stop hook's continuation signal was too vague (`reason: "continue"`), causing the model to re-route through `/workflow-orchestrator:delegate` and re-enter plan mode indefinitely. Three-layer fix: (1) Stop hook now emits explicit anti-redelegation directive in `reason` field, (2) orchestrator stub exception for continuation after plan approval, (3) delegate skill RE-INVOCATION GUARD at entry point.
- **Narrow continuation guard triggers** (Qodo review feedback). Layer 2 and Layer 3 guards now trigger only on the deterministic Stop-hook continuation marker, not the broader "most recent tool call was ExitPlanMode" heuristic. Explicit tool whitelist added for the exception path.

## [2.0.0] - 2026-04-08

Re-tag of `1.18.0` as a major release to honor semver. The same code, tagged honestly.
Expand Down
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 you arrived here via a "PLAN ALREADY APPROVED" or "continuing to STAGE 1" continuation message from the Stop hook, 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. In this path, the `Agent` tool (plus `TaskCreate`/`TaskUpdate`/`TaskGet`, and `TeamCreate`/`SendMessage` in team mode) is permitted for spawning Wave 0 phases. 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 you received a "PLAN ALREADY APPROVED" or "continuing to STAGE 1" continuation message from the Stop hook, **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. In this exception path, the `Agent` tool (plus `TaskCreate`/`TaskUpdate`/`TaskGet` for status, and `TeamCreate`/`SendMessage` if running in team mode) is permitted — these are how Wave 0 phases are spawned. The "all work → delegate" rule above does NOT apply during in-flight delegation continuation.

## 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