Why Effect Fits LLM Orchestration

James Phoenix
James Phoenix

LLMs are stochastic. Your infrastructure cannot be. Effect gives you deterministic orchestration around non-deterministic cores.


The Problem LLMs Create

When you introduce LLMs into a system, you get non-deterministic outputs, long-running workflows, retries with backoff, partial failures, distributed side effects, and async tool calls that may or may not happen.

If your codebase is impure, implicit, and unstructured, it collapses fast. LLMs increase the surface area of uncertainty. You need something that reduces uncertainty structurally.


The Triple: Effect<A, E, R>

Effect is not “better TypeScript.” It is a runtime algebra for effects.

Effect<A, E, R>
Symbol Meaning
A Success type
E Error type
R Required environment

That triple is a contract: this computation produces A, may fail with E, and requires R.

An LLM call is a function: f(prompt, tools, memory) -> distribution(output). Wrap it inside Effect<Output, LLMError, LLMEnv> and you can retry, backoff, timeout, fallback to another model, log, trace, memoize, and sandbox. All algebraically composable.


One Way of Doing Things

Effect enforces a single composition model. Every operation, whether it is an HTTP call, a database query, an LLM invocation, or a file read, flows through the same Effect<A, E, R> pipeline.

This matters for LLM systems because:

  • Errors are typed, not thrown. You know exactly what can fail and handle it explicitly.
  • Dependencies are declared, not hidden. No globals, no singletons, no mystery utils imports. The OpenAI client, embeddings store, memory graph, task registry, OTEL tracer are all visible in the R type parameter.
  • Composition is the default. You pipe, flatMap, and layer. There is no second way.

When a team (or an agent) reads Effect code, the type signature tells them everything: what it does, how it fails, and what it needs. That is cognitive compression applied to code.


Why LLM Systems Specifically

LLM-driven agent loops are not web apps. They are distributed state machines with failure semantics. That requires:

Capability Why It Matters for LLMs
Structured concurrency Run multiple tool calls in parallel, cancel on first success
Deterministic interruption Kill a runaway generation without leaking resources
Retry schedules Exponential backoff on rate limits, model fallback chains
Resource scoping Ensure API clients and connections are cleaned up
Layered dependency injection Swap real LLM for a mock in tests without changing code
Built-in observability OpenTelemetry tracing baked in, not bolted on

Plain TypeScript with “good discipline” does not scale under entropy. LLMs increase entropy. Agent swarms increase it further. Effect reduces entropy by making illegal states harder to represent.


Effect + Temporal = Control Plane Clarity

Temporal handles distributed durability: workflow persistence, replay, durable execution across failures.

Effect handles local reasoning purity: in-process algebra, deterministic composition, type-safe failure modelling.

Together:

  • Temporal = distributed durability (the macro control plane)
  • Effect = local reasoning (the micro control plane)

That stack matches how compound systems should work. Observability, feedback, and control at every layer.


The Cathedral Warning

Effect is powerful. It can also become a purity trap.

Use it for:

  • Domain logic
  • Invariant enforcement
  • Orchestration pipelines
  • Anything with meaningful failure modes

Do not use it for:

Leanpub Book

Read The Meta-Engineer

A practical book on building autonomous AI systems with Claude Code, context engineering, verification loops, and production harnesses.

Continuously updated
Claude Code + agentic systems
View Book
  • Simple CRUD
  • UI glue
  • Trivial adapters

The rule: abstraction should follow entropy density. If a workflow is stochastic, has retry semantics, requires tracing, and has meaningful failure states, then Effect is justified. If it is a simple data fetch, use boring TypeScript.

Pain, then pattern, then abstraction. Not abstraction, then hope for pain.


Summary

Effect is not a trend. It is the correct abstraction layer for building systems where deterministic control wraps probabilistic intelligence. The Effect<A, E, R> triple makes every computation’s contract explicit. Combined with Temporal for distributed durability, it gives you a complete control plane: macro durability from Temporal, micro reasoning purity from Effect.

The bet is simple: as LLM orchestration complexity rises, the value of typed, composable, observable effect systems rises with it.


References

Related

Topics
Agent OrchestrationFunctional ProgrammingReliabilityState Management

Newsletter

Become a better AI engineer

Weekly deep dives on production AI systems, context engineering, and the patterns that compound. No fluff, no tutorials. Just what works.

Join 306K+ developers. No spam. Unsubscribe anytime.


More Insights

Cover Image for Measuring Coding Agent Leverage

Measuring Coding Agent Leverage

Token volume measures spend, not output. Leverage is what your agents turn into verified, valuable change per unit of human attention, compute, and rework, and no single number captures it. You have to triangulate from several points of view.

James Phoenix
James Phoenix
Cover Image for Using DSL Languages for LLM Harnesses

Using DSL Languages for LLM Harnesses

Unmesh Joshi’s article [DSLs Enable Reliable Use of LLMs](https://martinfowler.com/articles/llm-and-dsls.html) (martinfowler.com, July 2026) names the endgame of something I have been documenting piecemeal for a year: the smaller the language you make the model speak, the less room it has to be wrong.

James Phoenix
James Phoenix