Skip to content

Ask: pass the stop reason as a typed value across the worker boundary #64

Description

@mchwang

Follow-up from PR #54 (Ask in the lane D container). Copilot's final review summary on validated head 6f047ac says "unresolved moderate issues remain in cancellation handling" but gives no finding or location. This issue records the most likely concrete cause, checked in the code. It is not a reproduced failure.

What the code does

The reason a question stops (timeout, shutdown, or user cancellation) crosses three layers only as message text:

  1. runner/questions.ts aborts with new Error('Agent timed out. Try again.') or new Error('Server stopped. Retry the question.').
  2. runner/question-agent.ts (#ask) posts { type: 'cancel', reason: signal.reason.message } to the worker.
  3. runner/question-worker.ts aborts with new Error(message.reason), and runner/question-container.ts (around line 208) rebuilds lane D's StopReason by regex: /timed out/ → timeout, /Server stopped/ → shutdown, otherwise cancelled.

AGENTS.md ("Async jobs and polling") requires the original timeout, cancellation and shutdown reason to be preserved through every layer. Matching on wording means changing a user-facing message silently changes the lane D stop reason, and the result is then reported as cancelled.

To close this issue

  • Carry the reason as a typed value (for example, StopReason or { kind: 'timeout' | 'shutdown' | 'cancelled', message }) from Questions through the bridge message and the worker to handle.cancel(). Keep the user-facing message separate.
  • Add a regression per reason. It should assert the StopReason that reaches the adapter and the persisted answer error. It must fail if a message's wording changes.
  • If investigation finds a different concrete cancellation defect behind the review summary, record it here instead.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions