Skip to content

Headless supervised discuss ends session before LLM can write CONTEXT file or ask multiple question rounds #3547

@bmanturner

Description

@bmanturner

Bug Description

gsd headless discuss --supervised --json ends the session prematurely after the first ask_user_questions tool call completes. The LLM never gets a chance to:

  1. Ask additional rounds of questions (it was thinking about "3-5 behavioral unknowns" but only got to ask 1)
  2. Write the S##-CONTEXT.md file with the discussion results

No CONTEXT.md file is ever produced, making headless supervised discuss non-functional for its intended purpose.

Root Cause

In src/headless.ts line 262:

const isMultiTurnCommand = options.command === 'auto' || options.command === 'next'

discuss is not classified as a multi-turn command. At line 640:

if (eventObj.type === 'execution_complete' && !completed && !isMultiTurnCommand) {
  completed = true
  // ...
  resolveCompletion()
  return
}

After the ask_user_questions tool receives a supervised response and the LLM turn ends, execution_complete fires. Since discuss is not multi-turn, the headless orchestrator immediately sets completed = true and calls resolveCompletion(), killing the session before the LLM can take another turn.

Steps to Reproduce

gsd headless discuss --supervised --json --response-timeout 300000
  1. Supervised orchestrator receives extension_ui_request for slice picker, responds
  2. GSD scans codebase (multiple bash tool calls across multiple turns — working correctly)
  3. LLM calls ask_user_questions tool, orchestrator receives extension_ui_request, responds
  4. Session ends immediately — no agent_end event, no further tool calls, no CONTEXT.md written

Expected Behavior

After the ask_user_questions tool receives the supervised response:

  1. The LLM should get another turn to process the answer
  2. The LLM should be able to call ask_user_questions again for additional question rounds
  3. The LLM should write S##-CONTEXT.md with the discussion results
  4. The session should end after the discuss workflow completes naturally

Suggested Fix

Add discuss to the multi-turn command classification, or use a different completion detection mechanism for discuss sessions (e.g., detect when the dispatchWorkflow discuss prompt has fully resolved via ctx.waitForIdle()).

const isMultiTurnCommand = options.command === 'auto' || options.command === 'next' || options.command === 'discuss'

Environment

  • GSD version: 2.63.0
  • OS: Linux
  • Node: v22.22.0

Workaround

Currently no viable headless workaround. The discuss command in headless supervised mode cannot produce CONTEXT.md files. Manual creation of CONTEXT.md files is required to satisfy the require_slice_discussion gate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions