From 39f78c641202cc9f3862d176d8735335d39091b0 Mon Sep 17 00:00:00 2001 From: Jonah Schulte Date: Mon, 26 Jan 2026 18:28:46 -0500 Subject: [PATCH] fix: allow slash commands in main context, enforce Task agents for internal calls **Problem:** - workflow.xml enforced Task agent for ALL workflow executions - User slash commands like /batch-super-dev need interactive prompts - Can't run in Task agent (no user interaction) **Solution:** - Detect invocation source - User slash command: Allow in main context - Internal workflow call: Force Task agent delegation **Detection:** - Slash command: User message contains '/bmad_' or tag - Internal call: Invoked from within another workflow step **Benefits:** - Interactive workflows work (user can respond to prompts) - Internal calls still get fresh context (Task agents) - Balance between enforcement and UX Tested: /bmad_bmm_batch-super-dev now runs without violation error. --- src/core/tasks/workflow.xml | 69 ++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/src/core/tasks/workflow.xml b/src/core/tasks/workflow.xml index 2dbaa4b7..c65370a9 100644 --- a/src/core/tasks/workflow.xml +++ b/src/core/tasks/workflow.xml @@ -18,45 +18,58 @@ 🚨 WORKFLOW EXECUTION ENFORCEMENT 🚨 - YOU ARE FORBIDDEN FROM EXECUTING THIS WORKFLOW DIRECTLY - YOU MUST DELEGATE TO workflow-executor TASK AGENT - IF you are reading this file directly (not as a Task agent): - HALT IMMEDIATELY + + IF this workflow was invoked by USER via slash command (e.g., /bmad_bmm_batch-super-dev): + ✅ ALLOWED in main context + Reason: User-initiated workflows need interactive prompts + Continue execution below - Display to user: - ❌ WORKFLOW EXECUTION VIOLATION DETECTED + ELSE IF this workflow was invoked by ANOTHER WORKFLOW (internal call): + ❌ FORBIDDEN in main context + MUST delegate to workflow-executor Task agent - You attempted to execute workflow: {workflow_path} + Display to user: + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + 🔄 Delegating workflow to fresh context agent... + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - This is FORBIDDEN. Workflows MUST be executed by workflow-executor Task agent. + Workflow: {workflow_name} + Reason: Internal workflow calls use Task agents (fresh context) - Correct action: - - subagent_type: general-purpose - description: Execute {workflow_name} - prompt: | - You are the workflow-executor agent. + Spawning workflow-executor agent... + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - LOAD EVERYTHING FIRST: - 1. Read: {workflow_path}/workflow.yaml - 2. Read: ALL files in {workflow_path}/steps/ - 3. Read: _bmad/core/tasks/workflow.xml - 4. Read: Story file - 5. Read: Project context + Then spawn: + + subagent_type: general-purpose + description: Execute {workflow_name} + prompt: | + You are the workflow-executor agent. - THEN execute workflow following workflow.xml EXACTLY. + Execute workflow: {workflow_path} - When step says invoke-workflow → Use Skill tool - When step says spawn agents → Use Task tool - When step has quality_gate → Verify before proceeding + LOAD ALL CONTEXT FIRST: + 1. Read: {workflow_path}/workflow.yaml + 2. Read: ALL files in {workflow_path}/steps/ + 3. Read: _bmad/core/tasks/workflow.xml + 4. Read: Story file (if applicable) + 5. Read: Project context - Record evidence after EVERY step. - Report back when ALL steps complete. - + THEN execute following workflow.xml rules EXACTLY. - STOPPING EXECUTION - Spawn the agent above. + Report when complete. + + + HALT - Let Task agent handle workflow. + + + + How to detect invocation source: + - Slash command: User message contains "/bmad_" or conversation has tag + - Internal call: No slash command, invoked from within another workflow step +