effect-ai-chat

Build stateful multi-turn AI chat sessions with the Effect Chat module.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires effect.

What problem does it solve? Managing conversation history, tool-call loops, and session persistence manually in AI applications is error-prone and repetitive. This Skill provides expert guidance for using the Effect v4 Chat module, which automatically accumulates history, serializes generations, and handles export/restore of chat state. ## Core Features & Use Cases - Stateful Conversations: Create chat sessions with system prompts, generate text or structured objects, and let the module manage history via an internal Ref<Prompt.Prompt>. - Agentic Tool Loops: Integrate Toolkit definitions so the model can call tools, handle approval requests, and loop until a final answer is produced. - Persistence & Streaming: Export sessions to JSON and restore them later, use Chat.Persistence for automatic saving, and stream responses with streamText. - Use Case: Build a support assistant service that keeps a conversation alive across turns, calls internal tools to look up order data, and persists the session to a database so users can resume later. ## Quick Start Ask the AI to create an Effect service that uses Chat.fromPrompt with a system prompt and generateText to answer user messages across multiple turns.

Frequently Asked Questions about effect-ai-chat

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

FAQPage Schema
How do I build a multi-turn chat with Effect TypeScript?

Use Chat.fromPrompt or Chat.empty from effect/unstable/ai to create a session, then call session.generateText with each user message. The Chat module automatically appends prompts and responses to history, so multi-turn context is preserved without manual management.

How do I add tool calling to an Effect Chat session?

Define tools with Tool.make and group them via Toolkit.make, then pass the toolkit option to generateText. Loop with an empty prompt until the model returns no tool calls; tool results are appended to history automatically.

Can I persist and restore an Effect Chat session?

Yes. Call session.exportJson to serialize the conversation, store the string anywhere, and restore it later with Chat.fromJson. For automatic saving after every generation, use Chat.layerPersisted with a BackingPersistence implementation.

Does Effect Chat support streaming responses?

Yes, session.streamText returns a Stream of response parts such as text-delta events. History updates when the stream finalizes, so consume the stream to completion if the full assistant reply should be recorded.

Why does generateText fail with a missing LanguageModel error?

Every generateText, streamText, and generateObject call requires LanguageModel.LanguageModel in its context. Provide it per call with Effect.provide(modelLayer) or at the layer level when wiring your service.

When should I use Chat instead of LanguageModel directly?

Use Chat for any multi-turn conversation because it manages history accumulation and serializes generations with an internal semaphore. Use LanguageModel.generateText directly only for isolated single-shot generations with no shared context.