← Wiki

Effect for AI agents: when it beats plain TypeScript and Vercel AI SDK

The short answer

Effect is a typed effect system for TypeScript: errors live in the type signature, and retries, timeouts, concurrency limits, cancellation, resource cleanup, dependency injection and tracing are part of the runtime instead of code you write by hand. It is not an LLM library. Vercel AI SDK calls the model; Effect runs everything around the call. The two combine: AI SDK inside an Effect program is a normal setup.

Decision rule. If the agent is “call a model, fill a schema, show the result”, stay on AI SDK (generateObject with a strict schema is already schema-guided-reasoning). Reach for Effect when the agent becomes a long-running pipeline: dozens of steps, parallel jobs with a limit, user-initiated cancel, partial failures that must not be lost, resume after a crash.

Where it pays off: a video-editing agent

Ingest 50 clips, transcribe, detect scenes and beats, let an LLM pick moments, render with ffmpeg, upload. On plain TypeScript every one of these needs its own code; in Effect each is one construct:

Need Plain TS + AI SDK Effect
50 clips, max 4 ffmpeg at once hand-written queue / semaphore Effect.forEach(clips, f, { concurrency: 4 })
User presses cancel ffmpeg and LLM requests keep running interruption kills the whole fiber tree
3 of 50 transcriptions fail try/catch, easy to swallow an error failure is in the type; skip, retry or stop is an explicit choice
Retry policy with backoff and budget loops copied into every call site one Schedule, reused everywhere
Temp files, GPU slots leak on crash acquireRelease cleans up even on cancel
Resume after a server crash at clip 40 start over @effect/workflow, durable like Temporal but in-process

Pros

Cons

How this connects

Related