#6496·gsd-2

Bug: Infinite recursion (OOM) when passing arguments to /gsd discuss, queue, visualize, or inspect

Author: jennifersousaudiCreated Sep 21, 2026Updated Sep 21, 2026

Problem

When a user runs /gsd discuss M001/S02 (or uses natural language that maps to it like talk about M001/S02), the application crashes with a "JavaScript heap out of memory" error due to infinite recursion in the command dispatcher.

Root Cause

In commands/dispatcher.js, if a command isn't matched by any specific handler (because of the extra arguments), it falls back to handleDo() in commands-do.js. handleDo() maps natural language to commands. For "discuss M001/S02", it matches the "discuss" keyword, extracts the remaining arguments "M001/S02", and re-dispatches the exact same string "discuss M001/S02" back to handleGSDCommand(). Because the handler in commands/handlers/workflow.js strictly checks trimmed === "discuss" (without trimmed.startsWith), it rejects the command again, sending it back to handleDo(). This infinite loop of promise allocations quickly exhausts the heap.

Vulnerable commands: discuss, queue, visualize, inspect.

Code snippet (commands/handlers/workflow.js)

javascript
    if (trimmed === "discuss") { // Fails on "discuss M001/S02"
        if (requireNotAutoActive("/gsd discuss", ctx))
            return true;
        await showDiscuss(ctx, pi, projectRoot());
        return true;
    }

Code snippet (commands-do.js)

javascript
    const match = matchRoute(args);
    if (match) {
        const fullCommand = match.remainingArgs
            ? `${match.command} ${match.remainingArgs}`
            : match.command;
        
        // When args == "discuss M001/S02", fullCommand is identically "discuss M001/S02".
        // Re-dispatching this causes infinite recursion.
        const { handleGSDCommand } = await import("./commands/dispatcher.js");
        await handleGSDCommand(fullCommand, ctx, pi);
        return;
    }

Expected Behavior

  1. Update commands-do.js to break the loop. If fullCommand === args, it means mapping the natural language command didn't yield a different string, so re-dispatching will definitely loop. In that case, either dispatch match.command without args, or show an error.
  2. Update the strict command handlers to accept trailing arguments so they capture the routing properly:
    javascript
    if (trimmed === "discuss" || trimmed.startsWith("discuss ")) {
        // handle
    }

Environment

  • GSD version: 3.0.0
  • Model: gemini-3.1-pro-low
  • Unit: Commands / Dispatcher

Reproduction Context

The user tried to discuss a specific slice (discuss M001/S02) via the command line or natural language. The command hit the dispatcher fallback logic and triggered the infinite loop.

Forensic Evidence

  • The process crash lock left behind indicates the crash brought down the entire auto-mode worker process abruptly without a clean exit.
  • execute-task M001/S02/T02 was logged in the crash lock merely because the command loop runs in the same node process, or the user invoked it during an interactive pause.

Auto-generated by /gsd forensics