Skip to content

fix: refuse a prompt stopped while it waits to start - #497

Merged
Sequela02 merged 2 commits into
devfrom
fix/stop-waiting-prompt
Oct 18, 2026
Merged

Sequela02 merged 2 commits into
devfrom
fix/stop-waiting-prompt

Conversation

@Sequela02

Copy link
Copy Markdown
Contributor

Part 7 of the move to Effect became fixing the places in the engine's loop that do not hear a stop (debated with GPT-6 Astra and GPT-6.1 Sol, and measured; the owner approved fixing them directly rather than moving loop.ts to Effect). This is a prompt stopped while it waits to start. Implemented by Sol (gpt-6.1-sol), who found it reading loop.ts; reproduced and checked by Claude, who added the print-mode case.

Defect

prompt() (packages/core/src/loop.ts) waits for the session's startup (session_start handlers) and for a manual compaction before it owns a controller; abort() stopped only what was already running. A prompt stopped while it waited then started with a fresh controller and ran. Reproduced on dev: a session_start handler held, a prompt sent, abort() awaited, the handler released; the run ended completed and its tool wrote its file.

Change

  • A prompt is admitted before its first wait (admitting); abort() and dispose() stop waiting admissions, and the prompt rechecks after each wait. A stopped prompt is refused: it rejects with the stop's reason before recording a request, so no run is added and the previous run's outcome stays. When it runs, its admission becomes the run's controller.
  • A prompt sent after the stop runs as before.
  • Print mode (print.ts) takes that refusal, after the operator's Ctrl+C or a termination, as the stop rather than an error: it ends "without a run" and exits 1, as a stop does, instead of printing the rejection with its stack. The shell already shows a rejected prompt's reason as a note.

Checks

  • New packages/core/tests/stop-admission.test.ts: a prompt stopped while waiting for startup, and one stopped while waiting for a manual compaction, run nothing, and a prompt after the stop runs. Both fail on dev (the stopped prompt's tool wrote its file) and pass with the change; checked by Sol and again by Claude.
  • With compaction-session, conformance and receipt-command tests: all pass.
  • bun run check (Sol, Windows): root 264 passed; engine 333 passed, 3 skipped; types and lint clean. The budget failed on shell memory on this machine (120.4 MB, limit 115 MB); CI decides.

Not covered by a test: the print-mode case (a stop by signal before the request starts).

A prompt waits for the session's startup and for a manual compaction before it owns a controller, and abort() only stopped what was already running, so a prompt stopped while it waited later ran with a fresh controller. It is now admitted, and stoppable, before its first wait, and refused when stopped; its admission becomes the run's controller. Print mode takes that refusal as the operator's stop rather than an error. Implemented by Sol (gpt-6.1-sol), who found it reading loop.ts; reproduced and checked by Claude, who added the print-mode case.
With a prompt stopped before it starts now refused, print mode would print that refusal with its stack after a Ctrl+C or a termination. It ends without a run and exits 1, as a stop does.
@Sequela02
Sequela02 force-pushed the fix/stop-waiting-prompt branch from 40b579e to 9612a1a Compare October 18, 2026 19:15
@Sequela02
Sequela02 merged commit c21a6c9 into dev Oct 18, 2026
9 checks passed
@Sequela02
Sequela02 deleted the fix/stop-waiting-prompt branch October 18, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant