effect-ai-streaming

Accumulate Effect AI stream parts into incremental history checkpoints.

22|1|Updated Apr 14, 2026
One-click install
npx skills add https://github.com/mpsuesser/pi-effect-harness --skill effect-ai-streaming-mpsuesser
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-ai-streaming
Source: https://github.com/mpsuesser/pi-effect-harness/tree/main/harnesses/effect/skills/effect-ai-streaming
Command: npx skills add https://github.com/mpsuesser/pi-effect-harness --skill effect-ai-streaming-mpsuesser

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you implement reliable, resource-safe streaming from Effect-based AI models while keeping conversation history consistent and concurrency under control.

Core Features & Use Cases

  • Stream protocol handling (start/delta/end): Normalize text, reasoning, tool-parameter, file, source, metadata, error, and finish parts into a predictable lifecycle.
  • Incremental accumulation + checkpointed history: Efficiently merge streamed parts into prompt history using Prompt.concat and SubscriptionRef to avoid reprocessing everything on each chunk.
  • Concurrency-safe streaming: Prevent overlapping stream runs using Semaphore and acquire/use/release patterns with Channel.acquireUseRelease.
  • Deterministic consumption strategies: Process parts with runForEach, drain, or fold, while correctly matching by part.type.
  • Operational guidance for safe matching: Use Match.when({ type: ... }) and avoid incorrect tag-based matching for StreamPart objects.

Quick Start

Implement Effect AI streaming by accumulating streamed StreamPart chunks, updating a SubscriptionRef-backed history checkpoint incrementally, and consuming parts using Match.when checks on part.type.

Frequently Asked Questions about effect-ai-streaming

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

FAQPage Schema
How do I handle AI streaming responses safely in Effect?

To handle AI streaming responses safely in Effect, you normalize start, delta, and end StreamPart sequences into incrementally accumulated outputs using Stream.mapChunksEffect, ensuring side-effectful accumulation without corrupting shared state.

How do I keep prompt history consistent during concurrent AI chat sessions?

Keeping prompt history consistent during concurrent AI chat sessions requires using SubscriptionRef to create incremental history checkpoints, combined with Prompt.concat to efficiently merge streamed parts without reprocessing the entire history on each chunk.

What is the best way to prevent overlapping stream runs in an Effect AI application?

Preventing overlapping stream runs in an Effect AI application is achieved by applying a Semaphore combined with Channel.acquireUseRelease, which enforces resource safety and concurrency control throughout the acquire, use, and release lifecycle.

Why does my Effect AI stream dispatch incorrectly when matching StreamPart objects?

Effect AI stream dispatch fails when using incorrect tag-based matching for StreamPart objects; you must use Match.when with explicit type checks like Match.when({ type: ... }) to correctly route text, reasoning, and tool-parameter parts.

Can I stream tool parameters and reasoning parts alongside text in an Effect chat UI?

Yes, you can stream tool parameters and reasoning parts alongside text in an Effect chat UI by normalizing the stream protocol lifecycle, allowing deterministic consumption strategies like runForEach or fold to process diverse part types predictably.