Skip to content

Bug: Composer agent hangs indefinitely during issue decomposition (no timeout enforcement) #394

@randomm

Description

@randomm

What happened

The Composer agent hangs indefinitely when decomposing GitHub issues into tasks. In testing, Composer ran for 20+ minutes without creating any tasks, leaving the job in "running" state with Pulse PID showing "none".

Expected behaviour

Composer should decompose issues within 2-3 minutes and either:

  • Successfully create tasks and hand off to Pulse
  • Time out with an error message after 5 minutes (per composer.ts:28)

Root Cause Analysis

Location: packages/opencode/src/tasks/composer.ts:51-54

The timeout mechanism exists but has a critical gap:

await Promise.race(
  SessionPrompt.prompt({ sessionID: session.id, agent: "composer", ... }),
  timeoutPromise,  // 5 minutes
)

Problem: The prompt() call blocks the entire event loop while the LLM processes. The 60+ line Composer prompt with 15+ rules may cause the LLM to take 5+ minutes just to process context before responding. The timeout fires but cannot interrupt an active prompt() call mid-execution.

Secondary issue: SessionPrompt.cancel() deletes session state, but the while(true) loop in prompt.ts:309 may not check abort.aborted until the next iteration, creating a race condition.

Steps to reproduce

  1. Create a moderately complex GitHub issue (e.g., test(taskctl): add utility function to validate branch name safety #393 with TDD requirements, acceptance criteria, test scenarios)
  2. Run taskctl start 393
  3. Observe: Job status shows "running" but no tasks created after 5+ minutes
  4. Pulse PID remains "none" (Pulse never starts because Composer hasnt finished)

Environment

Acceptance Criteria

  • Composer times out after 5 minutes with clear error message
  • Job transitions to "failed" state with actionable error (not stuck in "running")
  • PM session receives notification: "Composer timed out for issue #N"
  • Add instrumentation logging: "Composer started at [timestamp]", "Composer timed out at [timestamp]"
  • Document in lievo/ or code comment: "Composer prompt should be < X tokens to avoid timeout"

Definition of Done

  • Timeout enforcement verified with test (mock slow LLM response)
  • No regression: normal Composer runs still complete successfully
  • Error message includes issue number and suggestions (e.g., "Simplify issue description")
  • Code review passed (security, type safety, architecture lenses)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions