Skip to content

fix(taskctl): notifyPM does not wake up PM session — creates assistant message but never calls SessionPrompt.prompt() #301

@randomm

Description

@randomm

Root Cause

notifyPM in pulse-verdicts.ts writes a synthetic assistant-role message to the PM session's message history, but never invokes SessionPrompt.prompt(). The PM's agentic loop only wakes up when SessionPrompt.prompt() is called — so the notification appears in the UI but the PM is never interrupted to act on it.

Key code path:

  • notifyPM creates an role: "assistant" message with providerID: "system"
  • The agentic loop in session/prompt.ts looks for the last user message to resume — assistant messages are skipped
  • No BackgroundTaskEvent.Completed is published, so auto-wakeup never fires
  • SessionPrompt.prompt() is never called directly

Fix

After writing the notification message to the DB, inject a synthetic user message and call SessionPrompt.prompt() directly on the PM session so the agentic loop resumes and the PM can act on the notification (retry, override, escalate, etc.).

The notification text should be the user message content so the PM sees it as an incoming request to respond to.

Acceptance Criteria

  • When a task fails, PM session wakes up autonomously and can retry/override/escalate
  • When a job completes, PM session wakes up autonomously
  • When a task succeeds, PM session wakes up (or at minimum task-failed/job-complete wake PM)
  • bun test passes
  • bun run typecheck passes

Quality Gates (Non-Negotiable)

  • TDD: Write tests before implementation
  • Coverage: 80%+ test coverage for new code
  • Linting: All code passes project linting rules
  • Local Verification: All tests pass locally before completion

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions