Skip to content

Commit 5812aa7

Browse files
authored
Merge pull request #42 from barkain/fix/delegate-plan-mode-loop
fix: break delegate→plan-mode→approve infinite loop
2 parents b65f6a8 + 2d378f8 commit 5812aa7

6 files changed

Lines changed: 24 additions & 4 deletions

File tree

.claude-plugin/marketplace.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"name": "workflow-orchestrator",
99
"source": "./",
1010
"description": "Delegation system with workflow orchestration, specialized agents, and parallel execution for Claude Code",
11-
"version": "2.0.0",
11+
"version": "2.0.1",
1212
"author": {
1313
"name": "Nadav Barkai"
1414
},

.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "workflow-orchestrator",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "Delegation system with workflow orchestration, specialized agents, and parallel execution for Claude Code",
55
"author": {
66
"name": "Nadav Barkai"

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

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

5+
## [2.0.1] - 2026-04-12
6+
7+
### Fixed
8+
9+
- **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.
10+
- **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.
11+
512
## [2.0.0] - 2026-04-08
613

714
Re-tag of `1.18.0` as a major release to honor semver. The same code, tagged honestly.

commands/delegate.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ argument-hint: [task description]
44
allowed-tools: Agent, Task, EnterPlanMode, ExitPlanMode, AskUserQuestion, TaskCreate, TaskUpdate, TaskGet, TaskList, ToolSearch, TeamCreate, SendMessage
55
---
66

7+
## RE-INVOCATION GUARD (READ FIRST)
8+
9+
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.
10+
711
# Workflow Orchestrator System Prompt
812

913
## Purpose

hooks/stop/python_stop_hook.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,13 @@ def check_workflow_continuation() -> bool:
173173
# This mimics ralph-wiggum's loop mechanism
174174
output = {
175175
"decision": "block",
176-
"reason": "continue",
177-
"systemMessage": "⚡ Workflow continuation: Proceeding to STAGE 1 execution.",
176+
"reason": (
177+
"PLAN ALREADY APPROVED. Execute Stage 1 NOW directly from the existing "
178+
"approved plan in context. DO NOT call /workflow-orchestrator:delegate. "
179+
"DO NOT call EnterPlanMode. DO NOT re-enter plan mode. "
180+
"Render the dependency graph and start spawning Wave 0 agents."
181+
),
182+
"systemMessage": "⚡ Continuing to STAGE 1 execution (plan already approved).",
178183
}
179184
print(json.dumps(output)) # noqa: T201
180185
logger.debug("Output block decision with 'continue' reason")

system-prompts/orchestrator_stub.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ Any user request that requires work — writing code, running tools, multi-step
1010

1111
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.
1212

13+
## Exception — continuation after plan approval
14+
15+
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.
16+
1317
## Team Mode
1418

1519
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.

0 commit comments

Comments
 (0)