effect-ai-streaming

Implements Effect AI streaming responses with start/delta/end protocol, accumulation, and resource-safe consumption.

1|Updated Aug 24, 2026
One-click install
npx skills add https://github.com/lambdasolver2/opencode-effect-harness --skill effect-ai-streaming-lambdasolver2
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-ai-streaming
Source: https://github.com/lambdasolver2/opencode-effect-harness/tree/main/packages/module-typescript/assets/skills/effect-ai-streaming
Command: npx skills add https://github.com/lambdasolver2/opencode-effect-harness --skill effect-ai-streaming-lambdasolver2

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires effect.

What problem does it solve? Handling real-time streaming responses from language models in Effect requires correctly processing start/delta/end stream parts, accumulating partial content, and managing conversation history without race conditions or resource leaks. ## Core Features & Use Cases - StreamPart Protocol Handling: Match text, reasoning, tool-params, finish, and error parts using Match.when with type checks. - Accumulation & History Management: Fold stream parts with Prompt.fromResponseParts and update conversation history atomically via SubscriptionRef. - Resource-Safe Streaming: Protect concurrent stream operations with Semaphore and Channel.acquireUseRelease. - Use Case: Build a chat interface where model responses stream incrementally to the UI while conversation history updates in real time and concurrent requests are serialized safely. ## Quick Start Use the effect-ai-streaming skill to implement a streaming chat handler that accumulates text deltas and updates history with SubscriptionRef.

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 streaming responses from Effect AI language models?

Use LanguageModel.streamText to get a Stream of StreamParts, then consume it with Stream.runForEach or Stream.mapChunksEffect. Match parts with Match.when({ type: 'text-delta' }) since stream parts use a type field, not _tag.

How to accumulate streaming text deltas in Effect Stream?

Use Stream.mapChunksEffect with a mutable array to append parts, then fold them with Prompt.fromResponseParts so start/delta/end IDs align. Avoid Stream.map for accumulation because side effects are ignored there.

Why does Match.tag not work on Effect AI stream parts?

Stream parts use a type field rather than the _tag convention, so Match.tag fails to discriminate them. Use Match.when({ type: 'text-delta' }, handler) or direct part.type checks instead.

How do I prevent concurrent streaming requests in Effect?

Wrap the stream in Channel.acquireUseRelease with a Semaphore: take the semaphore on acquire, stream in the use phase, and release is guaranteed even on failure. This serializes access to shared history state.

How do I update conversation history while streaming?

Keep a checkpoint of history before streaming, accumulate response parts, then set a SubscriptionRef to Prompt.concat(checkpoint, Prompt.fromResponseParts(accumulated)) on each chunk for atomic incremental updates.