Skip to content

fix(workflow): use Skill instead of Task for auto-advance phase transitions#826

Open
Tibsfox wants to merge 1 commit intogsd-build:mainfrom
Tibsfox:fix/auto-advance-nesting
Open

fix(workflow): use Skill instead of Task for auto-advance phase transitions#826
Tibsfox wants to merge 1 commit intogsd-build:mainfrom
Tibsfox:fix/auto-advance-nesting

Conversation

@Tibsfox
Copy link
Contributor

@Tibsfox Tibsfox commented Feb 28, 2026

Summary

The auto-advance chain (discuss → plan → execute triggered by --auto) was spawning each subsequent phase as a Task(subagent_type="general-purpose"), creating 3-4 levels of nested agent sessions. At that depth, the Claude Code runtime hits resource limits or stdio contention, causing the execute-phase to either freeze indefinitely or attempt to shell out to claude as a subprocess — which is explicitly blocked with "Claude Code cannot be launched inside another Claude Code session."

The nesting looks like this:

discuss-phase (level 0)
  └─ Task(general-purpose) → plan-phase (level 1)
       └─ Task(general-purpose) → execute-phase (level 2)
            └─ Task(gsd-executor) → executor agents (level 3)
                 └─ ...potential further nesting (level 4)

By level 2-3, the general-purpose agent loses context about the execute-phase orchestration protocol and falls back to shelling out to claude --print, which triggers the nested session error.

The Fix

Replace Task(general-purpose) with Skill() invocations for phase transitions:

discuss-phase (level 0)
  └─ Skill("gsd:plan-phase") → plan-phase (level 0, same context)
       └─ Skill("gsd:execute-phase") → execute-phase (level 0, same context)
            └─ Task(gsd-executor) → executor agents (level 1)

The Skill tool runs in the same process context as the caller — it doesn't create a subprocess or new agent session. This keeps the entire orchestration chain flat at level 0, with only the actual worker agents (gsd-executor, gsd-verifier, etc.) spawning as Task subagents at level 1.

Changes

  • workflows/plan-phase.md (step 14): Replace 30-line Task(general-purpose) block with Skill("gsd:execute-phase", args="${PHASE} --auto --no-transition")
  • workflows/discuss-phase.md (auto_advance step): Replace 30-line Task(general-purpose) block with Skill("gsd:plan-phase", args="${PHASE} --auto")

Net effect: -67 lines of complex Task prompt engineering, +13 lines of clean Skill invocations.

Verification

  1. Run /gsd:discuss-phase <phase> --auto
  2. Complete the discussion flow
  3. Auto-advance should trigger plan-phase (via Skill, not Task)
  4. Plan-phase should auto-advance to execute-phase (via Skill, not Task)
  5. Execute-phase should spawn gsd-executor agents normally
  6. No "nested session" errors, no freezes

Why Skill Instead of Task?

The previous code had a comment: "do NOT use Skill tool — Skills don't resolve inside Task subagents". This was correct for the original architecture where each phase ran inside a Task. But the fix here changes the architecture: phases now chain via Skill at the top level, so the resolution concern doesn't apply. Each Skill invocation runs with full access to the command registry.

Closes #686

🤖 Generated with Claude Code

…itions

The auto-advance chain (discuss → plan → execute) was spawning each
subsequent phase as a Task(subagent_type="general-purpose"), creating
3-4 levels of nested agent sessions. At that nesting depth, the
Claude Code runtime hits resource limits or stdio contention, causing
the execute-phase to freeze or attempt to shell out to `claude` as a
subprocess (which is explicitly blocked).

The fix replaces Task spawns with Skill invocations for phase
transitions:
- discuss-phase auto-advance: Skill("gsd:plan-phase") instead of
  Task(general-purpose)
- plan-phase auto-advance: Skill("gsd:execute-phase") instead of
  Task(general-purpose)

The Skill tool runs in the same process context as the caller,
keeping the entire auto-advance chain flat at a single nesting level.
Each phase still spawns its own worker agents (gsd-executor,
gsd-planner, etc.) as Tasks, but the orchestration chain itself
no longer creates unnecessary depth.

Closes gsd-build#686

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-advance chain freezes at execute-phase — nested Claude Code session error

1 participant