effect-uai-mid-stream-abort

Cancel in-flight model turns using Effect's Stream.interruptWhen and Deferred signaling.

30|4|Updated Apr 26, 2026
One-click install
npx skills add https://github.com/betalyra/effect-uai --skill effect-uai-mid-stream-abort
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-uai-mid-stream-abort
Source: https://github.com/betalyra/effect-uai/tree/main/skills/effect-uai-mid-stream-abort
Command: npx skills add https://github.com/betalyra/effect-uai --skill effect-uai-mid-stream-abort

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Use this Skill when you need to cancel an in-flight model turn cleanly — e.g. user clicks "stop", a new prompt arrives mid-generation, or a deadline elapses. The upstream HTTP connection drops via Effect's structured concurrency; partial deltas already emitted stay with the consumer.

Core Features & Use Cases

  • Mid-turn abort with Stream.interruptWhen and Deferred signaling to stop a running turn gracefully.
  • Safe teardown: finalizers run end-to-end, including aborting the underlying fetch.
  • Use cases include interactive chat interfaces, long-running generations, and deadline-driven prompts.

Quick Start

Integrate the mid-stream abort pattern in your turn processing to allow users to stop in-flight generations.

Frequently Asked Questions about effect-uai-mid-stream-abort

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I cancel an in-flight model turn safely in a streaming application?

Cancel an in-flight model turn safely using Effect's Stream.interruptWhen and Deferred-based signaling to interrupt the active stream and tear down the underlying fetch request. This pattern provides safe teardown and preserves partial deltas for downstream handling.

What happens to partial streaming deltas when a user aborts generation mid-stream?

When a mid-stream abort occurs, partial deltas already emitted stay with the consumer. Upstream HTTP connections drop via Effect's structured concurrency, ensuring finalizers run end-to-end to abort the underlying fetch request.

How do I stop a running LLM generation gracefully when a new prompt arrives?

Stop a running generation gracefully by integrating the mid-stream abort pattern in your turn processing. It uses Deferred signaling to interrupt the active stream when a new prompt arrives, stopping the in-flight model turn safely.

Can I use Effect's structured concurrency to abort an underlying fetch request during streaming?

Yes, Effect's structured concurrency supports safe teardown of an underlying fetch request during streaming. Stream.interruptWhen triggers finalizers end-to-end, aborting the upstream HTTP connection when canceling an in-flight model turn.

When do I need mid-stream cancellation for interactive chat interfaces?

Mid-stream cancellation is needed for interactive chat interfaces when a user clicks stop, a new prompt arrives mid-generation, or a deadline elapses. It allows you to cancel an in-flight model turn safely without losing partial deltas.